Capability 013: Java Builds and Coverage¶
Status: Accepted
Context¶
A coverage agent instruments classes while the JVM loads them. A build therefore never contains instrumented code and needs one output directory only. One runner runs the programmed tests and a second one the scenarios, each in a JVM of its own. Both JVMs get the agent and write into the same coverage data file, so the scenarios count like the programmed tests. This capability defines the builds and how the Java profiles measure the figure of capability 011.
References¶
Details¶
Builds:
| Build | Output | Configuration | Used by |
|---|---|---|---|
| Classes | target/classes |
Compiled, no instrumentation | build, test, bdd-test, coverage |
| Package | target/*.jar |
As Classes, packaged without running the tests | release-build, package |
The container images build their package on their own and are not affected.
Test runners:
| Runner | Runs | Target |
|---|---|---|
| Runner of the programmed tests | *Test.java, *CT.java |
test, coverage |
| Runner of the scenarios | The scenario suite | bdd-test, coverage |
Neither runner runs *IT.java, the Integrative Tests of capability 011.
Coverage:
| Aspect | Value |
|---|---|
| Metric | Lines |
| Counted | The runs of both runners, in one coverage data file |
| Excluded | The Application class |
| Threshold | The coverage tool's check, run by coverage |
Functional Requirements¶
testandbdd-testrun the runners of Details, and neither runs an Integrative Test.coverageruns both runners with the agent and reports their counts together, as Details defines.- No build contains instrumented classes.
Non-Functional Requirements¶
None.
Technical Requirements¶
- Maven builds, Surefire runs the programmed tests with JUnit, Failsafe runs the scenarios with Cucumber, and the JaCoCo agent counts. The testing guideline prescribes JUnit and Cucumber, and the Java CI image provides the rest.
Error Handling¶
None.
Out of Scope¶
- What capability 011 defines for every language
- The architecture test, which
arch-testruns apart from the programmed tests
Acceptance Criteria¶
- Java library and Java service: the runner of the programmed tests includes
*Test.javaand*CT.javaand excludes the scenario suite and*IT.java. The runner of the scenarios includes the scenario suite only. - Java library and Java service: the scenario suite's name ends neither in
Test,CT, norIT. - Java library and Java service: the coverage agent is prepared for both runners, with one
coverage data file, and the report excludes
Application. - Generated Java service, a method reached only by a scenario:
make coveragereports it as covered (manual testtest/manual/generated_coverage.md).
Decisions¶
- Runners split by explicit patterns, not by Maven's defaults.
Failsafe's default runs
*IT.java, which capability 011 assigns to Integrative Tests. Consequence: both runners name their patterns inpom.xml. - The agent, not offline instrumentation. The agent leaves the build untouched, so no build needs a directory of its own. Consequence: every JVM that runs tests for the figure needs the agent.