Test coverage is a lie
Test coverage is a metric, and any metric can be gamed. Test coverage can be gamed very easily: Ensure that for every piece of code, there is a test that runs it. However:
- Don’t assert anything
- Only execute one branch (unless branch coverage is enabled)
- Catch and ignore all exceptions
Now you have 100% test coverage and a useless test suite.
See also
- Weeknotes 2023 W19: Stub, where I talk about how stubbing can decrease the value of test suites.
- Don’t set test coverage delta requirements