Test Overview
This test uses two @pytest.mark.parametrize decorators to run a function with all combinations of two sets of inputs. It verifies the sum of two numbers equals the expected result.
This test uses two @pytest.mark.parametrize decorators to run a function with all combinations of two sets of inputs. It verifies the sum of two numbers equals the expected result.
import pytest @pytest.mark.parametrize('a', [1, 2]) @pytest.mark.parametrize('b', [10, 20]) def test_sum(a, b): result = a + b assert result == a + b # simple check to confirm sum calculation
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | pytest test runner initialized | - | PASS |
| 2 | pytest collects test_sum with parameters a=[1,2] and b=[10,20] | Test cases generated for all combinations: (a=1,b=10), (a=1,b=20), (a=2,b=10), (a=2,b=20) | - | PASS |
| 3 | Test case runs with a=1, b=10 | Function test_sum called with a=1, b=10 | Assert result == 11 | PASS |
| 4 | Test case runs with a=1, b=20 | Function test_sum called with a=1, b=20 | Assert result == 21 | PASS |
| 5 | Test case runs with a=2, b=10 | Function test_sum called with a=2, b=10 | Assert result == 12 | PASS |
| 6 | Test case runs with a=2, b=20 | Function test_sum called with a=2, b=20 | Assert result == 22 | PASS |
| 7 | All test cases completed | All combinations tested successfully | - | PASS |