Home:ALL Converter>jenkins uiautomator build always green

jenkins uiautomator build always green

Ask Time:2013-08-08T03:26:21         Author:Arzath

Json Formatter

So I defined many UiAutomatorTestCase classes, each has 1 or 2 test cases at the most. Then I use Shell script on Jenkins to string these test cases into a series of tests, for example:

adb shell uiautomator runtest myTest.jar -c com.myTest.TestClass1
adb shell uiautomator runtest myTest.jar -c com.myTest.TestClass2
adb shell uiautomator runtest myTest.jar -c com.myTest.TestClass3
adb shell uiautomator runtest myTest.jar -c com.myTest.TestClass4
...
so on so forth.

one of the two (1/2) problems I have is that with Jenkins builds, it doesn't matter if any of these test fails, Jenkins always shows up as green, I need Jenkins stop and shows red for the build.

the other (2/2) problem is that if the app crashes in one of the tests, say, TestClass2, the script will try to pick up and continue executing. What would be the best method to make the script stop?

Any suggestions? Thanks

Author:Arzath,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/18112086/jenkins-uiautomator-build-always-green
Arzath :

Thanks to @KeepCalmAndCarryOn and Daniel Beck, I solved my problem by 2 steps:\n\n\nlog adb output\ngrep the keyword from the log\n\n\nthe code in the shell script would be:\n\n#!bin/bash\n\nfunction punch() {\n \"$@\" | tee ${WORKSPACE}/adb_output.log\n [[ -z \"$(grep 'FAILURES!!!' ${WORKSPACE}/adb_output.log)\" ]] || exit 1\n}\n\npunch adb shell uiautomator runtest myTest.jar -c com.myTest.TestClass1\npunch adb shell uiautomator runtest myTest.jar -c com.myTest.TestClass2\n...\n",
2013-08-09T15:43:15
yy