Commit 22203bea authored by Aneta Steimarova's avatar Aneta Steimarova

#691 WIP Running more tests one by one enabled.

parent 1714137f
......@@ -266,7 +266,34 @@ idea {
}
}
//TODO make android iTest runner like in desktop->build.gradle
def runTest(String iTestName) {
println "[iTest] STARTING TEST: " + iTestName
def adb = doAndroidSettings()
exec {
commandLine "$adb", 'shell', 'am', 'start', '-n', 'cz.nic.tablexia.itest/cz.nic.tablexia.android.AndroidITestLauncher', '-e', 'testClassName', iTestName
}
def adbStdOut = new ByteArrayOutputStream()
while(true) {
//TODO test ends in PROCESSING state (nothing found with: adb shell ps cz.nic.tablexia.itest)
/*if(adbStdOut.toString().trim().contains("PROCESSING")){
def adbPS = new ByteArrayOutputStream()
exec {
commandLine "$adb", 'shell', "ps", "cz.nic.tablexia.itest"
standardOutput = adbPS
}
if(!adbPS.toString().contains("cz.nic.tablexia.itest")) return
}*/
if(adbStdOut.toString().trim().contains("OK")) return
if(adbStdOut.toString().trim().contains("FAIL")) return
exec {
commandLine "$adb", 'shell', "ls", "/sdcard/iTest_results"
standardOutput = adbStdOut
}
}
}
task runAndroidITestBundle {
doLast{
int testsCount = 0;
......@@ -274,6 +301,10 @@ task runAndroidITestBundle {
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 adb = doAndroidSettings()
println "[iTest] INSTALLING Tablexia (iTest) into connected Android device"
......@@ -283,22 +314,23 @@ task runAndroidITestBundle {
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'
}
println "[iTest] OLD FILES on SDCARD REMOVED"
testsCount++
runTest(iTestName)
println "[iTest] TEST: " + iTestName + " FINISHED"
exec {
commandLine "$adb", 'shell', 'am', 'start', '-a', "android.intent.action.MAIN", '-n', "cz.nic.tablexia.itest/cz.nic.tablexia.android.AndroidITestLauncher", '-e', "testClassName", "NewUserScenario"
commandLine "$adb", 'pull', '/sdcard/iTest_results', "${project(':android').projectDir}/build/outputs/apk/"
}
println "[iTest] Test NewUserScenario finished."
println "[iTest] LOG FILES WERE MOVED INTO " + iTestOutputFile.toString()
}
println "[iTest] $testsCount" + " tests were found in iTestBundle.txt"
}
/*println "[iTest] RUNNING Android tests"
workingDir "${project(':itest').projectDir}"
commandLine "./runAndroidITests.sh"*/
file("$iTestOutputFile").eachFile { logFile ->
if(logFile.toString().contains("OK")) successfulTestsCount++;
}
//TODO make counting files work
/*iTestOutputFile.traverse(type : FileType.FILES, nameFilter: ~/OK_.*\.log/) { iTestLog ->
successfulTestsCount++;
}*/
// if (testsCount != successfulTestsCount) throw new GradleException("Failed to complete all iTests! Check iTest log files in: \'${iTestOutputPath}\'")
if (testsCount != successfulTestsCount) throw new GradleException("Failed to complete all iTests! Check iTest log files in: " + TestOutputFile.toString())
}
}
\ No newline at end of file
NewUserScenario
\ No newline at end of file
NewUserScenario
TestScenarioSpecial
\ 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