I am attempting to get JUnit test reports from our continuous integration Jenkins builds into Sonar for our Android project. I'm a hair's breadth from success and I can't figure out the last step.
The build is done with Ant.
I'm using the Jenkins-started emulator and running the tests with the missing android XML JUnit test runner. The tests run, and I successfully pull the JUnit XML results files (com.my.package.thing-TEST.xml
, etc.) off the device into a designated directory using the instructions provided by the test runner's authors.
The Sonar analysis is done using the "Invoke Standalone Sonar Analysis" build step provided by The Jenkins Sonar plugin. I've got the project properties set up so that all the static source analysis and such is all successfully being pushed to the Sonar server.
My problem is that it won't push the JUnit test results along with all the rest of the analysis. I've followed the Sonar instructions about reusing test reports. Notably, I've set these properties:
sonar.dynamicAnalysis=reuseReports
sonar.surefire.reportsPath=android/REDACTED-test/junit-results
I can see in the build output where it should be parsing the results:
17:52:28.013 INFO org.sonar.INFO - Execute Findbugs 2.0.0 done: 25446 ms
17:52:28.378 INFO p.PhasesTimeProfiler - Sensor FindbugsSensor done: 25812 ms
17:52:28.378 INFO p.PhasesTimeProfiler - Sensor SurefireSensor...
17:52:28.379 INFO s.p.s.SurefireSensor - parsing /jenkins/jobs/REDACTED/workspace/android/REDACTED-test/junit-results
17:52:28.383 INFO p.PhasesTimeProfiler - Sensor SurefireSensor done: 5 ms
17:52:28.383 INFO p.PhasesTimeProfiler - Sensor CpdSensor...
17:52:28.384 INFO o.s.p.cpd.CpdSensor - SonarEngine is used
I've logged onto the build machine to have a peek in the directory mentioned, and I've confirmed that there are several JUnit XML files there, but for some reason, the Sonar server is still reporting zero tests. Since the SurefireSensor is only taking 5 ms, I'm pretty sure it's not seeing and/or opening the results files, but I don't know why. Can anyone help?
The runner produces test result names in the format:
android.package.name-TEST.xml
The emma surefire plugin finds only .xml files whose names start with "TEST-"
.
The missing android XML test runner, unfortunately, provides only suffix functionality, so you will have to alter each file name manually by adding "TEST-"
to the front.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With