Skip to content

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

  1. test and bdd-test run the runners of Details, and neither runs an Integrative Test.
  2. coverage runs both runners with the agent and reports their counts together, as Details defines.
  3. No build contains instrumented classes.

Non-Functional Requirements

None.

Technical Requirements

  1. 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-test runs apart from the programmed tests

Acceptance Criteria

  1. Java library and Java service: the runner of the programmed tests includes *Test.java and *CT.java and excludes the scenario suite and *IT.java. The runner of the scenarios includes the scenario suite only.
  2. Java library and Java service: the scenario suite's name ends neither in Test, CT, nor IT.
  3. Java library and Java service: the coverage agent is prepared for both runners, with one coverage data file, and the report excludes Application.
  4. Generated Java service, a method reached only by a scenario: make coverage reports it as covered (manual test test/manual/generated_coverage.md).

Decisions

  1. 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 in pom.xml.
  2. 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.