22
Systems + delivery / Intermediate

Testing and debugging

Unit, integration, regression, security, migration, and deployment tests plus a systematic debugging method.

testingpytestdebuggingregressionci

01Testing layers

LayerPurpose
UnitPure logic in isolation
IntegrationDatabase/framework/components together
RegressionA fixed bug must stay fixed
SecurityAuthorization, CSRF, lockouts, validation
MigrationSchema upgrades from supported states
SmokeApp 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.