Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: running instrumented tests on TeamCity server

I am building an Android Studio/Gradle project on TeamCity server. I am somewhat new to TeamCity. Currently, the unit tests auto-generated by Android Studio are run automatically when the project is built on TeamCity and are displayed under "Tests" . I also have an instrumented test (a test which runs on the connected android device), but it does not get run automatically like the unit tests do.

My solution was to add a Gradle build step in TeamCity to run the instrumented test. So far, I've had little success. I used the gradle tasks uninstallAll connectedAndroidTest, which runs the instrumented test, but the test result does not show up under "Tests" along with the unit tests. If the instrumented test fails, the build fails, but the failed test still does not show up under "Tests".

What am I doing wrong? Is there a correct way to run instrumented tests on TeamCity?

like image 753
Andrew Farm Avatar asked Jun 08 '17 20:06

Andrew Farm


People also ask

What is instrumented testing in Android?

Instrumented tests run on Android devices, whether physical or emulated. As such, they can take advantage of the Android framework APIs. Instrumented tests therefore provide more fidelity than local tests, though they run much more slowly.


1 Answers

The connectedAndroidTest will output files specifying test results according to this pattern:

HTML test result files: path_to_your_project/module_name/build/outputs/reports/androidTests/connected/ directory. XML test result files: path_to_your_project/module_name/build/outputs/androidTest-results/connected/ directory. (from here)

Using that output file you can use the XML Report Processing feature of TeamCity. In your Build Configuration just go to the Build Features tab and add the XML Report Processing feature. Use the Google Test option and point it to the report output directory like so: Adding XML report processing build feature

After that you should see your instrumented test results show up in your builds just like regular JUnit tests:

build results including tests

like image 69
Egg Avatar answered Sep 24 '22 08:09

Egg