Test Overview
This test runs a simple function and measures code coverage to verify that all lines of the function are executed during the test. It shows how coverage helps check if tests cover all parts of the code.
This test runs a simple function and measures code coverage to verify that all lines of the function are executed during the test. It shows how coverage helps check if tests cover all parts of the code.
def add(a, b): return a + b def test_add(): result = add(2, 3) assert result == 5
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | pytest test runner is ready | - | PASS |
| 2 | pytest runs test_add function | Function add is called with arguments 2 and 3 | - | PASS |
| 3 | add function executes return statement | Returns 5 to test_add | - | PASS |
| 4 | test_add asserts result equals 5 | Assertion compares result (5) with expected (5) | assert result == 5 | PASS |
| 5 | Coverage tool measures executed lines in add function | All lines in add function marked as executed | Coverage shows 100% lines covered | PASS |
| 6 | Test ends with coverage report | Report shows full coverage of add function | - | PASS |