SDLC Automation

A CodeBuild project runs unit tests for a Java service. The team wants line coverage trends shown in CodeBuild for every build, and builds must fail automatically when line coverage drops below 80%. Which configuration meets these requirements?

Show the answer

Correct answerB. Add a reports section with the JaCoCo XML coverage file, and run the tests with the coverage tool's 80% check so a shortfall returns a nonzero exit code.

AWhy not this: Report groups collect and display coverage; they have no setting that fails a build below a threshold.

BWhy this is right: The reports section gives coverage trends, and the coverage tool's check fails the build command when coverage is below 80%.

CWhy not this: A build artifact is not a coverage report, and an alarm cannot fail a build that has already finished.

DWhy not this: A manual approval depends on people reading the report rather than failing the build automatically.

A coverage report in the buildspec's reports section lets CodeBuild show line and branch coverage over time. CodeBuild does not enforce coverage thresholds itself, so the test command must fail when coverage is too low; a nonzero exit code fails the build.