Test Overview
This test checks a simple function with an if-else branch. It verifies that both branches are tested to achieve full branch coverage.
This test checks a simple function with an if-else branch. It verifies that both branches are tested to achieve full branch coverage.
def is_even(num): if num % 2 == 0: return True else: return False import pytest def test_is_even(): assert is_even(4) == True assert is_even(5) == False
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | pytest test runner initialized | - | PASS |
| 2 | Calls is_even(4) | Function receives input 4 | Check if 4 % 2 == 0 branch is taken | PASS |
| 3 | Returns True for input 4 | Function returns True | Assert returned value is True | PASS |
| 4 | Calls is_even(5) | Function receives input 5 | Check if else branch is taken for 5 | PASS |
| 5 | Returns False for input 5 | Function returns False | Assert returned value is False | PASS |
| 6 | Test ends | All assertions passed | Branch coverage achieved for both if and else | PASS |