Condition Coverage
Condition Coverage is a white-box testing metric that evaluates the extent to which individual conditions within a decision statement have been tested. It ensures that each condition in a decision (e.g., a logical expression) has been evaluated to both true and false outcomes at least once during testing.
Condition coverage focuses on testing the boolean expressions within code, helping identify scenarios where specific conditions might lead to incorrect behavior or untested logic paths.
Key Aspects of Condition Coverage:
- Conditions: These are the boolean sub-expressions within a decision. For example, in the statement
if (A && B),AandBare the conditions. - Outcomes: Each condition must independently evaluate to
trueandfalseto satisfy condition coverage. - Partial Coverage: Achieving condition coverage does not guarantee that all combinations of conditions within a decision are tested (which is covered by Multiple Condition Coverage).
Purpose of Condition Coverage:
- Defect Detection: Ensures that every condition contributing to a decision is independently evaluated, helping identify defects in logical expressions.
- Improved Test Quality: Encourages thorough testing of individual conditions, leading to better coverage of the codebase.
- Risk Mitigation: Reduces the risk of untested code paths, particularly in complex decision-making logic.
Benefits of Condition Coverage:
- Enhanced Defect Detection: Helps uncover defects in individual conditions that might be overlooked with broader metrics.
- Granularity: Provides a detailed view of which conditions have been thoroughly tested.
- Compliance: Often required for safety-critical systems, such as in aviation or medical software.





