Explanation

Code coverage and mutation testing answer different questions

Why can tests with high code coverage still miss bugs?

Code coverage records which code ran. A test can execute a branch without checking the result that matters. Mutation testing examines whether the tests detect selected changes in behaviour, which gives a different view of the strength of their assertions.

What can coverage tell you?

An unexecuted branch is a clear place to investigate. A measured branch hit tells you the path ran during the test, while the test’s assertions determine whether a wrong result would be noticed. Read both the inputs and the expected outcomes before interpreting a coverage percentage.

What does a mutation score add?

A mutation run makes small changes and records how the suite responds. Review surviving changes alongside the scope, tool’s treatment of timeouts, excluded code and changes that have equivalent behaviour. A percentage calculated for one selection of changes cannot describe every possible defect.

Worked example

The unexamined delivery charge

A test requests a quote, receives a successful response and covers the branch that adds a delivery charge. Changing the charge from five pounds to zero still leaves a successful response. An assertion against an agreed quote total exposes the change and explains exactly what the first test missed.

Try it on your pull request

Choose a change in your repository and tell Cue April what should happen. Review the proposed checks before they run.

Try Cue April on your repository