Skip to content

Module 06: Testing, Debugging, And Quality

Learn to prove behavior, find root causes, and prevent repeated failure.

Testing is controlled questioning. Debugging is evidence-driven investigation. Quality is reducing the cost and frequency of failure.

expectation -> experiment -> evidence -> conclusion

A doctor does not randomly prescribe medicine for chest pain. They observe symptoms, ask questions, run tests, isolate likely causes, treat, and monitor. Debugging works the same way.

TestWhat It Proves
UnitSmall logic behaves correctly
IntegrationComponents talk correctly
End-to-endUser path works through the system
ContractAPI shape stays compatible
RegressionA known bug does not return
SmokeDeployed system is basically alive

evidence-first debugging

SymptomWhat user or system sees.
ReproduceMake it happen on demand.
IsolateNarrow component and boundary.
EvidenceLogs, data, test, trace.
Root causeOriginal trigger, not surface effect.
FixSmallest durable repair.
VerifyProve old failure is gone.
PreventRegression test or guardrail.
  • Write tests around risky behavior.
  • Validate at boundaries.
  • Log important state changes.
  • Use request IDs.
  • Keep errors specific.
  • Make rollback possible.
  • Write postmortems without blame.

Bug: duplicate tickets are created.

Investigate:

  • Is submit button disabled while loading?
  • Does the client retry?
  • Does the backend use idempotency?
  • Does the database enforce uniqueness where appropriate?
  • Are queue jobs processed twice?
  • Do logs show two requests or one request with two writes?

Ask an agent:

Given this duplicate ticket bug report and the code paths, propose a debugging
plan. Do not suggest fixes until reproduction and evidence are defined.
  • What is the difference between symptom and root cause?
  • Why is a passing test not always enough?
  • What makes a log useful during an incident?
  • What should a postmortem include?
  • What is the smallest regression test for a bug?
  • Why should duplicate prevention exist beyond the UI?
  1. Create portfolio/06-testing-debugging-quality/debugging-log.md.
  2. Introduce or find one bug.
  3. Reproduce it.
  4. Capture evidence.
  5. Write a failing test.
  6. Fix the root cause.
  7. Verify with test and runtime evidence.
  8. Write a postmortem.
  9. Add one prevention mechanism.
  • The bug is reproducible.
  • The root cause is named.
  • A test catches the old behavior.
  • The fix is verified.
  • The postmortem explains prevention.