Introduction
When testing software, it is important to check that every part of the code works correctly. One challenge is to make sure that all the different conditions in decisions are tested, so no hidden errors remain.
Imagine a security system with multiple sensors, like a door sensor and a window sensor. Condition coverage is like testing each sensor separately to make sure it triggers correctly when opened or closed.
┌───────────────────────────────┐ │ Decision (if) │ │ ┌───────────────┐ ┌───────────┐ │ │ │ Condition A │ │ Condition B│ │ │ └──────┬────────┘ └─────┬─────┘ │ │ │ │ │ │ True / False True / False│ └────────┴────────────────┴───────┘
def check_access(age, has_ticket): if age >= 18 and has_ticket: return "Access granted" else: return "Access denied" # Tests for condition coverage print(check_access(20, True)) # Both conditions true print(check_access(16, True)) # age false, has_ticket true print(check_access(20, False)) # age true, has_ticket false print(check_access(16, False)) # Both conditions false
condition coverage ensure in software testing?&& inside parentheses.&&. if a and b then ... uses incorrect syntax (no parentheses, wrong keywords). if (a & b) { ... } uses bitwise AND &, not logical AND. if a && b { ... } misses parentheses.if (x > 0 && y == 5). Which test inputs achieve full condition coverage?if (a || b) {
// do something
}a || b, condition coverage requires testing a and b each as true and false separately.if ((p && q) || r). Which minimal test set achieves full condition coverage?Pass the test and this pattern moves unknown