A tiny Python + pytest starter
Understand a readable test before building a large automation framework.
1. Install pytest
Create a virtual environment and run python -m pip install pytest.
2. Write one behavior-focused test
Use an assert statement and give the function a descriptive name starting with test_.
3. Parameterize examples
Use @pytest.mark.parametrize to cover multiple inputs without duplicating code.
4. Run and iterate
Execute python -m pytest -q and inspect the assertion output.
Example test
import pytest
@pytest.mark.parametrize('a,b,expected', [
(2, 3, 5),
(-1, 1, 0),
(0, 0, 0),
])
def test_addition(a, b, expected):
assert a + b == expectedKey takeaway
Start with simple deterministic functions, then graduate to APIs and browser tests.