Export test results for instrumented Android tests

First of all, sorry if this has been asked before, but I searched for a while and couldn’t find anything.

All of the tests in my app are instrumented (i.e. live under src/androidTest and require a device/emulator to run). I used a combination of “AVD Manager”, “Wait for Android emulator” and “Gradle Runner” invoking the connectedDevelopDebugAndroidTest task (develop is the build flavor I’m testing) in order to get these tests to run as part of my build, and it’s working great. However, I’m having a hard time exporting the results of these tests.

I followed the instructions here and added a “Export test results to the Test Reports add-on”, but I’m still getting the “Test Reports wasn’t configured correctly” message when trying to view results.

If I run the connectedDevelopDebugAndroidTest task locally, the reports are generated under ./app/build/reports/androidTests/connected/flavors/DEVELOP. In that folder, there is an index.html file, some JS and CSS folders, and then one HTML file for each of my test classes.

Here’s the configuration I used for the “Export test results” step:

- custom-test-results-export@0:
        inputs:
        - search_pattern: "*"
        - base_path: "./app/build/reports/androidTests/connected/flavors/DEVELOP/"
        - test_name: Android Instrumented Tests

The way I’m reading the documentation, it implies that search_pattern should match only one of those HTML files, but then how do I get it to export all of them? Am I doing something obviously wrong?

Ok, so it looks like I was looking in the wrong place, the test results xml file was in ./app/build/outputs/androidTest-results/connected/flavors/DEVELOP/. There is still one weird thing were every test case was grouped under a single “Test suite” in the report, but at least all the data is there.

For posterity, this is the updated configuration:

- custom-test-results-export@0:
        inputs:
        - search_pattern: "*"
        - base_path: "./app/build/outputs/androidTest-results/connected/flavors/DEVELOP/"
        - test_name: Android Instrumented Tests
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.