Commit eecc1d93 authored by Aneta Steimarova's avatar Aneta Steimarova

#691 Added checking if Tablexia apk exists, refactoring

parent 22203bea
......@@ -299,30 +299,39 @@ task runAndroidITestBundle {
int testsCount = 0;
int successfulTestsCount = 0;
println "[iTest] CREATING NEW iTest OUTPUT DIRECTORY"
def iTestOutputFile = new File("${project(':android').projectDir}/build/outputs/apk/iTest_results/")
if (iTestOutputFile.exists()) {
println "[iTest] REMOVING OLD iTest OUTPUT DIRECTORY"
iTestOutputFile.deleteDir()
def tablexiaApk = project.tablexiaAppName + "-iTest-" + "$tablexiaVersionName" + ".apk"
def apkFolder = "${project(':android').projectDir}/build/outputs/apk/"
def sdCardResults = "/sdcard/iTest_results"
println "[iTest] INSTALLING " + tablexiaApk + " into connected Android device"
if(!new File(apkFolder + tablexiaApk).exists()){
throw new GradleException("Could not install " + tablexiaApk + " - file does not exists!")
return
}
def adb = doAndroidSettings()
println "[iTest] INSTALLING Tablexia (iTest) into connected Android device"
exec {
commandLine "$adb", 'install', '-r', "${project(':android').projectDir}/build/outputs/apk/" + "Tablexia (androidITest-gradle)-iTest-" + "$tablexiaVersionName" + ".apk"
commandLine "$adb", 'install', '-r', apkFolder + tablexiaApk
}
println "[iTest] INSTALLING Tablexia COMPLETED"
println "[iTest] CREATING NEW iTest OUTPUT DIRECTORY"
def iTestOutputFile = new File(apkFolder + "iTest_results/")
if (iTestOutputFile.exists()) {
println "[iTest] REMOVING OLD iTest OUTPUT DIRECTORY"
iTestOutputFile.deleteDir()
}
println "[iTest] INSTALLING Tablexia (iTest) into connected Android device complete"
new File("${project(':itest').projectDir}/iTestBundle.txt").eachLine { iTestName ->
exec {
commandLine "$adb", 'shell', 'rm', '-r', '/sdcard/iTest_results'
commandLine "$adb", 'shell', 'rm', '-r', sdCardResults
}
println "[iTest] OLD FILES on SDCARD REMOVED"
testsCount++
runTest(iTestName)
println "[iTest] TEST: " + iTestName + " FINISHED"
exec {
commandLine "$adb", 'pull', '/sdcard/iTest_results', "${project(':android').projectDir}/build/outputs/apk/"
commandLine "$adb", 'pull', sdCardResults, apkFolder
}
println "[iTest] LOG FILES WERE MOVED INTO " + iTestOutputFile.toString()
}
......@@ -331,6 +340,6 @@ task runAndroidITestBundle {
if(logFile.toString().contains("OK")) successfulTestsCount++;
}
if (testsCount != successfulTestsCount) throw new GradleException("Failed to complete all iTests! Check iTest log files in: " + TestOutputFile.toString())
if (testsCount != successfulTestsCount) throw new GradleException("Failed to complete all iTests! Check iTest log files in: " + iTestOutputFile.toString())
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment