Software Testing MOC
Hub for automated testing across languages: which level a test belongs at, keeping tests independent, and what to put in place of real dependencies.
Core concepts
Test levels & practice
- Unit, Integration and End-to-End Tests Trade Speed for Realism: the pyramid, FastAPI's
TestClientas a fast integration test, FactoryBotbuildvscreate, red-green-refactor. - Django's Test Case Classes Differ by How Much Database and Server They Set Up:
SimpleTestCase,TestCase,TransactionTestCase,LiveServerTestCase.
Isolation & test data
- Tests That Share State Pass or Fail Depending on Their Order: state pollution,
autousereset fixtures, random ordering to prove isolation. - A Mocked Database Lets Broken SQL Pass, an In-Memory Database Runs It: mocks vs SQLite
:memory:, environment-driven database paths and engines. - Point the App at a Test Database Before It Imports Its Connection: overriding the database in
conftest.pybefore the import.
Routing tests
- Routes Match in Declaration Order, So a Dynamic Path Can Shadow a Static One: why routes are tested through a client, not by calling handlers.
Related maps
- FastAPI MOC: the app most of these tests target.
- Django MOC: Django's own test tooling.
- Programming Languages MOC: Python language notes.
References
- pytest documentation - fixtures, plugins and configuration.
- Martin Fowler: The Practical Test Pyramid - test levels in practice.