Test Overview
This test checks if all possible branches (true and false paths) in a simple decision are executed. It verifies that the code correctly handles both conditions.
This test checks if all possible branches (true and false paths) in a simple decision are executed. It verifies that the code correctly handles both conditions.
def is_even(num): if num % 2 == 0: return True else: return False def test_is_even(): assert is_even(4) == True # Tests the 'true' branch assert is_even(5) == False # Tests the 'false' branch if __name__ == '__main__': test_is_even()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test environment is ready with the is_even function loaded | - | PASS |
| 2 | Calls is_even(4) | Function receives input 4 | Checks if 4 % 2 == 0 evaluates to True | PASS |
| 3 | Returns True for input 4 | Function returns True | Assert that returned value is True | PASS |
| 4 | Calls is_even(5) | Function receives input 5 | Checks if 5 % 2 == 0 evaluates to False | PASS |
| 5 | Returns False for input 5 | Function returns False | Assert that returned value is False | PASS |
| 6 | Test ends | All assertions passed, both branches covered | Branch coverage achieved for both true and false paths | PASS |