Test Overview
This test runs a simple function and uses pytest-cov to check how much of the code is covered by the test. It verifies that the coverage report shows 100% coverage for the tested function.
This test runs a simple function and uses pytest-cov to check how much of the code is covered by the test. It verifies that the coverage report shows 100% coverage for the tested function.
import pytest def add(a, b): return a + b def test_add(): assert add(2, 3) == 5 # To run coverage: pytest --cov=./ --cov-report=term-missing
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts by running pytest with coverage plugin enabled | Terminal ready to run pytest command | - | PASS |
| 2 | pytest discovers test_add function in test file | pytest test collection complete | - | PASS |
| 3 | pytest runs test_add which calls add(2, 3) | Function add executes and returns 5 | assert add(2, 3) == 5 | PASS |
| 4 | pytest-cov collects coverage data during test run | Coverage data recorded for add function | - | PASS |
| 5 | pytest finishes and prints coverage report showing 100% coverage for add function | Terminal displays coverage summary with no missing lines | Coverage report shows 100% coverage | PASS |