22
Systems + delivery / Intermediate
Testing and debugging
Unit, integration, regression, security, migration, and deployment tests plus a systematic debugging method.
01Testing layers
| Layer | Purpose |
|---|---|
| Unit | Pure logic in isolation |
| Integration | Database/framework/components together |
| Regression | A fixed bug must stay fixed |
| Security | Authorization, CSRF, lockouts, validation |
| Migration | Schema upgrades from supported states |
| Smoke | App starts and critical routes work in production-like config |
02Pytest example
pythonTest the failure path
def test_average_rejects_empty_list():
with pytest.raises(ValueError):
average([])
03Debugging method
- Reproduce reliably.
- Capture the exact error/trace/log and inputs.
- Identify the first frame owned by your application.
- Form one hypothesis and test it with the smallest change/observation.
- Add a regression test before or with the fix.
- Verify the deployed artifact/commit, not only local code.