Testing with pytest
This section covers testing fundamentals and the pytest framework — the standard testing tool in Python.
Topics
| Page | What You Will Learn |
|---|---|
| Testing Fundamentals | Unit vs integration vs E2E tests, test pyramid |
| pytest Basics | Test structure, assertions, running tests |
| Fixtures & Parametrize | Fixtures, parametrization, markers |
| Test Architecture | Project structure, naming, organization, POM, Singleton, Factory |
| Assertions & Mocking | Custom assertions, mocks, stubs, monkeypatching |
Key Points
- Tests should be independent — each test runs on its own
- Tests should be deterministic — same result every time
- Tests should be fast — slow tests slow down development
- Use fixtures to set up test data, not copy-paste