Fix the site test report and count Android in the coverage - #82
Fix the site test report and count Android in the coverage#82ppkarwasz wants to merge 3 commits into
Conversation
The site's Surefire report counted zero tests: the eight surefire executions write into target/surefire-reports/<flavor>, while the report plugin scans target/surefire-reports itself. List the eight directories. Take the non-forking goals while here. The `report` goal forks the test phase, and in the forked lifecycle the first execution is configured with a mixture of the other executions' settings (Xerces added, Saxon excluded, xpath3 skipped, failures ignored), so `mvn test site` ran a ninth, misconfigured test round that overwrote the real Saxon reports. `report-only` reads what the build produced instead. The directory list is scoped to that report set so `failsafe-report-only` keeps its own default, target/failsafe-reports. Assisted-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XVaEa2R2sHtBgJh8Mhv841
The device suite in android-tests exercises the platform-parser paths no JVM run reaches, but its results never reached JaCoCo: the Gradle build collected no coverage, and nothing merged it into the Maven data. Turn on the Android Gradle plugin's androidTest coverage, pinned to the JaCoCo version the Maven build reports with so the on-device agent and the report agree on the data format. The plugin instruments the whole test APK, the library JAR under test included, and leaves one execution data file per device under build/outputs/code_coverage. Merge those files into target/jacoco.exec in the site lifecycle, so jacoco:report shows the Android-only paths as covered. The merge stays out of the default lifecycle on purpose: jacoco:check keeps measuring the JVM run alone, so the coverage minimums mean the same thing whether or not a device run is lying around. With no Android run in the tree the merge is a no-op, and JaCoCo drops execution data whose class no longer matches, so a stale run cannot inflate the numbers. Document the round trip in the module README, along with the JDK 8 plus JDK 21 recipe that reaches the project's real coverage, and correct the excluded-tag list while there: the suite runs the schema tests against the Xerces on the androidTest classpath, and it is xpath that stays out, since XPathFactory.newDefaultInstance has no Android fallback and the leak controls expect an unconfigured XPath to fetch. Assisted-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XVaEa2R2sHtBgJh8Mhv841
The minimums were unreachable: mvn -Pjacoco clean verify violated five of the six rules on every JDK, because much of the library only runs on Java 8 (the MethodHandle fallbacks, the absent newDefaultInstance and newNSInstance, the pre-18 XPathFactory) or only on a device. Measure what one runtime reaches and set each minimum a point below the weaker of a JDK 8 and a JDK 21 run: instructions 94.02% and 95.89%, branches 88.59% and 89.67%, lines 94.78% and 95.51%, complexity 93.63% and 95.75%, methods 96.57% and 99.21%, classes 97.14% on both. The check now passes on JDK 8, 11, 17, 21 and 25, while a run accumulated across JDK 8, JDK 21 and Android clears every rule by three points or more. Assisted-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XVaEa2R2sHtBgJh8Mhv841
|
Hi @ppkarwasz |
|
I haven't tested extensively, but sometimes the results of previous tests are overwritten, while other times appended. And of course a |
| <commons.jacoco.classRatio>0.96</commons.jacoco.classRatio> | ||
| <commons.jacoco.instructionRatio>0.93</commons.jacoco.instructionRatio> | ||
| <commons.jacoco.methodRatio>0.95</commons.jacoco.methodRatio> | ||
| <commons.jacoco.branchRatio>0.87</commons.jacoco.branchRatio> | ||
| <commons.jacoco.lineRatio>0.93</commons.jacoco.lineRatio> | ||
| <commons.jacoco.complexityRatio>0.92</commons.jacoco.complexityRatio> |
There was a problem hiding this comment.
How is it that running more tests lowers the test coverage percentages?
Sorry, now I understand the question.
The values were lowered, so that a single build on any JDK passes them. This way if you run:
mvn -Pjacoco clean verifythe build passes and you don't need to run multiple -Pjacoco test on multiple JDKs, before you can run verify.
This is already the case in where the So what's going on that causes the numbers for you to fail? |
Three related fixes to how the build reports on its own tests.
The site's Surefire report counted zero tests. The eight surefire executions write into
target/surefire-reports/<flavor>, while the report plugin scanstarget/surefire-reportsitself. It also used the forkingreportgoal, and in the forked lifecycle the first execution is configured with a mixture of the other executions' settings (Xerces added, Saxon excluded, failures ignored), somvn test siteran a ninth, misconfigured test round that overwrote the real Saxon reports. Nowreport-onlyover the eight directories;failsafe-report-onlykeeps its own default.The Android instrumented run never reached JaCoCo. The Gradle build now enables the Android Gradle plugin's androidTest coverage, pinned to the JaCoCo version the Maven build reports with, and the
jacocoprofile merges the resulting execution data intotarget/jacoco.execbefore the site report. The merge sits in the site lifecycle only, sojacoco:checkkeeps measuring the JVM run alone and the minimums mean the same thing on every machine.The coverage minimums were unreachable.
mvn -Pjacoco clean verifyviolated five of the six rules on every JDK, because much of the library only runs on Java 8 or only on a device. They are now a point below what the weaker of a JDK 8 and a JDK 21 run reaches on its own.Verified:
mvn -Pjacoco clean verifypasses the coverage check on JDK 8, 11, 17, 21 and 25.mvn clean test siteruns each surefire execution exactly once; the report shows 1159 tests and the failsafe page its own 2.connectedDebugAndroidTest, JDK 8 pass, JDK 21 pass) clears every rule: instructions 97.99%, branches 96.74%, lines 97.94%, complexity 98.51%, methods 99.74%, classes 100%.Build and documentation only, no main code changes.
🤖 Generated with Claude Code