Skip to content
Ameen Abozaid
Planned lessonJNR-043-L05

Coverage and its limits

  • Lesson 5 of 6
  • Junior
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

read a coverage report and not be fooled by it.

Planned topics

  • Coverage tools (for example JaCoCo) show which lines and branches ran during tests.
  • Low coverage shows untested code; high coverage does not show tested behavior.
  • A test with no assertions gives coverage and no protection.
  • Mutation testing changes your code on purpose; if tests still pass, the mutant "survived" and the test is weak.
  • Use coverage to find gaps, not as a target to hit.
Draft outline details

Demonstration

a method isAdult(age) with a test that calls it and asserts nothing: 100% line coverage, zero protection. Then a mutation (>= to >) survives.

Check your understanding

Can 100% coverage coexist with a bug?

Show answer

Yes; running a line is not checking its result.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.