Which statement best describes condition coverage in software testing?
Think about testing each part of a decision separately.
Condition coverage means each condition in a decision must be true and false at least once, regardless of the overall decision outcome.
Consider the following code snippet:
def check_values(a, b):
if a > 0 and b > 0:
return "Both positive"
else:
return "Not both positive"If tests run with inputs (1, 1) and (1, -1), what is the condition coverage achieved?
Check the values of a and b in each test case.
In (1,1), both conditions are true. In (1,-1), a > 0 is true but b > 0 is false. So a > 0 is true both times, never false.
Given the function below, which assertion set best helps achieve condition coverage for the decision?
def is_eligible(age, income):
if age >= 18 and income > 20000:
return True
else:
return FalseEach condition must be true and false at least once.
Option C tests age >= 18 true and false, income > 20000 true once and false once, covering both conditions true and false.
Test cases for the function below achieve full condition coverage. Which statement best describes the coverage?
def check_access(user_role, is_active):
if user_role == "admin" or is_active:
return "Access granted"
else:
return "Access denied"
# Test cases:
# 1. ("admin", True)
# 2. ("user", True)
# 3. ("admin", False)Check if each condition is true and false at least once.
The test cases evaluate user_role == "admin" true (1,3) and false (2), is_active true (1,2) and false (3), achieving full condition coverage.
Which test framework feature best supports measuring condition coverage automatically during test runs?
Focus on tools that measure condition evaluation, not just line execution.
Condition coverage analyzers track each condition's true and false evaluations, which is needed to measure condition coverage.