Test Overview
This test checks a function that adds two numbers. It uses multiple parameters to test different pairs of numbers and verifies the sum is correct.
This test checks a function that adds two numbers. It uses multiple parameters to test different pairs of numbers and verifies the sum is correct.
import pytest @pytest.mark.parametrize("a,b,expected", [ (1, 2, 3), (5, 5, 10), (10, -2, 8), (0, 0, 0) ]) def test_addition(a, b, expected): result = a + b assert result == expected, f"Expected {expected} but got {result}"
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | pytest test runner initialized | - | PASS |
| 2 | Test runner reads @pytest.mark.parametrize with parameters (a,b,expected) | Test cases prepared for each parameter set | - | PASS |
| 3 | Test case 1 runs with a=1, b=2, expected=3 | Function adds 1 + 2 | Check if result == 3 | PASS |
| 4 | Test case 2 runs with a=5, b=5, expected=10 | Function adds 5 + 5 | Check if result == 10 | PASS |
| 5 | Test case 3 runs with a=10, b=-2, expected=8 | Function adds 10 + (-2) | Check if result == 8 | PASS |
| 6 | Test case 4 runs with a=0, b=0, expected=0 | Function adds 0 + 0 | Check if result == 0 | PASS |
| 7 | All parameterized tests complete | Test report generated with all passes | - | PASS |