Test Overview
This test checks a simple function with two conditions combined by AND. It verifies that each condition is tested both true and false at least once, ensuring condition coverage.
This test checks a simple function with two conditions combined by AND. It verifies that each condition is tested both true and false at least once, ensuring condition coverage.
def check_conditions(a, b): if a > 0 and b > 0: return True else: return False import unittest class TestConditionCoverage(unittest.TestCase): def test_condition_coverage(self): # Test case 1: a > 0 true, b > 0 true self.assertTrue(check_conditions(1, 1)) # Test case 2: a > 0 false, b > 0 true self.assertFalse(check_conditions(0, 1)) # Test case 3: a > 0 true, b > 0 false self.assertFalse(check_conditions(1, 0)) if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initialized | - | PASS |
| 2 | Calls check_conditions(1, 1) | Function evaluates a > 0 (true) and b > 0 (true) | AssertTrue passes because both conditions true | PASS |
| 3 | Calls check_conditions(0, 1) | Function evaluates a > 0 (false) and b > 0 (true) | AssertFalse passes because first condition false | PASS |
| 4 | Calls check_conditions(1, 0) | Function evaluates a > 0 (true) and b > 0 (false) | AssertFalse passes because second condition false | PASS |
| 5 | Test ends | All assertions passed | All conditions covered true and false | PASS |