Test Coverage Metrics
Test coverage metrics answer the question: how much of our code is executed by our tests?
2 main metrics:
The most commonly used metric.
The downside of using it that code can be "shuffled" to trick the metric into increasing. This can sometimes make code less readable.
Code can't be simplify shuffled without refactor, as branches will be examined whether one line or multiple.
The downside, which covers all code coverage metrics, is that tests without assertions will be counted as branch traversal.
Khorikov (2020) (pg. 8-15)
Vladimir Khorikov. Unit Testing: Principles, Practices, and Patterns. Manning, Shelter Island, NY, 2020. ISBN 978-1-61729-627-7. ↩