Branch coverage measures the ratio of conditional branches executed by a test suite to the total branches in production code. It reveals more about test completeness than line coverage, but it remains a negative indicator: low coverage signals trouble, while high coverage does not prove test quality. section 1.3 section 1.6
Figure 1.4. The branch metric is calculated as the ratio of the number of code branches exercised by the test suite and the total number of branches in the production code base.
Use the branch-ratio diagram to distinguish executed conditional paths from total paths. section 1.3
One of two paths covered
For IsStringLong, a test using "abc" exercises the false path but not the true path for strings longer than five characters. The result is 50% branch coverage, even though the test contains an assertion. section 1.3
Apply branch coverage as feedback rather than a target:
- Investigate low coverage, especially in core system areas. section 1.6
- Do not impose a required coverage percentage; it creates perverse incentives. section 1.6
- Check assertions and important behavior separately, because branch coverage does not show whether tests verify outcomes. section 1.6
- Weigh coverage benefits against test maintenance costs and retain tests with positive net value. section 1.6


