EnricoMi / publish-unit-test-result-action

GitHub Action to publish unit test results on GitHub
Apache License 2.0
625 stars 184 forks source link

androidTest / Could not find any files for test-results/**/*.xml #564

Closed johnjohndoe closed 9 months ago

johnjohndoe commented 9 months ago

Context

I like to see test results both for unit and instrumentation tests for my Android application project. It contains a few different Gradle modules (android application, android library, kotlin library) and tests in the test and androidTest source sets. Also, it contains multiple product flavors. Here is the workflow configuration: 7760612891/workflow

Current state

Test results for unit tests (test source set) are written to the respective module build/test-results/ folders, e.g. app/build/test-results/testCcc37c3DebugUnitTest/TEST-nerd.tuxmobil.fahrplan.congress.alarms.AlarmServicesTest.xml. These XML files are then correctly picked up by the publish-unit-test-result-action.

image

Test results for instrumentation tests (androidTest source set) seem to be missing and therefore are not picked up.

Could not find any files for test-results/*/.xml

image

The instrumentation tests are part of the database module. They do not target UI but still need the Android framework to run. See: database/androidTest

Related

EnricoMi commented 9 months ago

Invoking the publish action twice requires individual check_name values, e.g.

Regarding the missing test results: your File listing step shows there are no TEST*.xml files in path .:

find . -name "TEST*.xml"
echo "All files:"
find .

There are no files listed before All files:

All files:
.

Further, there is no test-results directory in ., so test-results/**/*.xml cannot find anything.

johnjohndoe commented 9 months ago

I added the check_name option now, see runs/7769998601.

Further, there is no test-results directory in ., so test-results/**/*.xml cannot find anything.

Do you know why the xml files are missing and how I can fix it?

When I run the tests locally on an emulator then the following files are generated:

└── outputs
    └── androidTest-results
        └── connected
            ├── TEST-Pixel_7_API_33(AVD) - 13-_database-.xml
            └── test-result.pb
EnricoMi commented 9 months ago

No idea, seems unrelated to this action, maybe you should check with https://github.com/reactivecircus/android-emulator-runner.

johnjohndoe commented 9 months ago

OK. I just confirmed that instrumentation tests are skipped: runs/7773288979/job/21196786085 :(

If you see no errors in the configuration for this action then you can close this issue. Thank you.

johnjohndoe commented 9 months ago

I fixed running the instrumentation tests now (I had to scope the Gradle task to the module) ...

script: ./gradlew :database:connectedAndroidTest

... and I can see an xml file being generated. See runs/7773831930.

./database/build/outputs/androidTest-results/connected/TEST-test(AVD) - 10-_database-.xml

It isn't picked up by the results action, though.

Warning: Could not find any files for androidTest-results/**/*.xml, */androidTest-results/**/*.xml
EnricoMi commented 9 months ago

Because androidTest-results/**/*.xml and */androidTest-results/**/*.xml cannot match ./database/build/outputs/androidTest-results/connected/TEST-test(AVD) - 10-_database-.xml.

Try **/androidTest-results/**/*.xml instead.

johnjohndoe commented 9 months ago

Awesome. It works now.

Screenshot of the connectedAndroidTest results

Thank you!