Module 06: Testing, Debugging, And Quality
Learn to prove behavior, find root causes, and prevent repeated failure.
The Mental Model
Section titled “The Mental Model”Testing is controlled questioning. Debugging is evidence-driven investigation. Quality is reducing the cost and frequency of failure.
expectation -> experiment -> evidence -> conclusionAnalogy
Section titled “Analogy”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.
Test Types
Section titled “Test Types”| Test | What It Proves |
|---|---|
| Unit | Small logic behaves correctly |
| Integration | Components talk correctly |
| End-to-end | User path works through the system |
| Contract | API shape stays compatible |
| Regression | A known bug does not return |
| Smoke | Deployed system is basically alive |
Debugging Loop
Section titled “Debugging Loop”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.
Quality Habits
Section titled “Quality Habits”- 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.
Debug Drill
Section titled “Debug Drill”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?
Agentic Angle
Section titled “Agentic Angle”Ask an agent:
Given this duplicate ticket bug report and the code paths, propose a debuggingplan. Do not suggest fixes until reproduction and evidence are defined.Questions
Section titled “Questions”- 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?
- Create
portfolio/06-testing-debugging-quality/debugging-log.md. - Introduce or find one bug.
- Reproduce it.
- Capture evidence.
- Write a failing test.
- Fix the root cause.
- Verify with test and runtime evidence.
- Write a postmortem.
- Add one prevention mechanism.
Done When
Section titled “Done When”- The bug is reproducible.
- The root cause is named.
- A test catches the old behavior.
- The fix is verified.
- The postmortem explains prevention.