Test Overview
This test checks that a simple calculator function adds numbers correctly. It shows how organizing tests clearly helps when projects grow bigger.
This test checks that a simple calculator function adds numbers correctly. It shows how organizing tests clearly helps when projects grow bigger.
import pytest def add(a, b): return a + b def test_add_positive_numbers(): assert add(2, 3) == 5 def test_add_negative_numbers(): assert add(-1, -1) == -2 def test_add_zero(): assert add(0, 0) == 0
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts and loads test functions | pytest collects test_add_positive_numbers, test_add_negative_numbers, test_add_zero | - | PASS |
| 2 | Runs test_add_positive_numbers | Function add(2, 3) returns 5 | Check if 5 == 5 | PASS |
| 3 | Runs test_add_negative_numbers | Function add(-1, -1) returns -2 | Check if -2 == -2 | PASS |
| 4 | Runs test_add_zero | Function add(0, 0) returns 0 | Check if 0 == 0 | PASS |
| 5 | Test runner finishes all tests | All tests passed successfully | - | PASS |