Andrew Farm
Andrew Farm

Reputation: 178

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?

Upvotes: 7

Views: 1298

Answers (2)

Egg
Egg

Reputation: 2056

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

Upvotes: 1

Mateusz Chrzaszcz
Mateusz Chrzaszcz

Reputation: 1280

You can tweak test task:

test.dependsOn uninstallAll, connectedAndroidTest

Another way would be to include your test (though not sure if this will work as I am not sure what uninstallAll and connectedAndroidTest tasks are doing): test {include 'org/foo/**'}

Upvotes: 0

Related Questions