Coverage Versus Safety¶
Run the Coverage Versus Safety MicroSim Fullscreen
About This MicroSim¶
Test coverage counts the lines that run during the tests. It does not count the risks the tests check. This MicroSim gives you a budget of five tests out of twelve and two meters: line coverage, and critical risks covered out of four.
The four risks come from the running example: the money path, the auth path, no false all-clear, and no-locate. The tests that guard them are small, so they add little coverage. The tests that add the most coverage guard none of them.
All coverage numbers are illustrative.
How to Use¶
- Click a test to pick it. Click it again to drop it. Both meters change at once.
- When five are picked, press Check my five.
- If a risk is left open, the sim names it and you get one more try. After a second miss, the four tests that cover the risks are outlined in green.
- Answer the follow-up question from the list and press Answer.
Try the set with the highest coverage first, then look at the risks meter.
Iframe Embed Code¶
You can add this MicroSim to any web page by adding this to your HTML:
<iframe src="https://arunbatchu.github.io/good-enough-engineering/sims/coverage-versus-safety/main.html"
height="644px"
width="100%"
scrolling="no"></iframe>
Lesson Plan¶
Grade Level¶
Adult professional (Good Enough Engineering)
Duration¶
10-15 minutes
Learning Objective¶
Prioritize five tests from a list of twelve for the dating-safety app so that all four critical risks are covered, and judge why the choice with the highest line coverage leaves risks open.
Prerequisites¶
- Test coverage
- Coverage is not safety
- Critical user path
- Test the money path
- Test the auth path
- Invariant test
Activities¶
- Exploration (3 min): Pick and drop tests and watch the two meters. Find the set with the highest coverage.
- Guided Practice (5 min): Build a set of five that covers all four risks. Note its coverage.
- Assessment (5 min): Answer the follow-up. Explain why tests 8 and 12 cover no risk.
Assessment¶
Mastery is a set that covers all four risks on the first or second attempt, plus the right answer to the follow-up question.
References¶
- Martin Fowler: Test Coverage - coverage finds untested code but is a poor target.
- Vitest: Coverage - how a test runner reports coverage.
- Google Testing Blog: Code Coverage Best Practices - why a coverage number is not a quality score.
