Skip to content

Day 049 — Week 3 Review + Recall

Month 2 · Week 3 · ⬅ Day 048 · Day 050 ➡ · Journal index

🎯 Learning Objective

Consolidate the week's testing toolkit (table-driven tests, parallelism, httptest, coverage, benchmarks, fuzzing, examples) with closed-book recall, then write the formal review.

📚 Topics

  • The testing package end to end: T, B, F
  • Tooling: go test -run/-bench/-fuzz/-cover/-race

📖 Reading / Sources

📝 Notes

  • One-line map of the week → [[testing-toolkit]]:
  • Correctness: table-driven t.Run subtests; t.Error (continue) vs t.Fatal (stop).
  • Speed/safety of tests: t.Parallel (+ tc := tc), t.Helper, t.Cleanup, t.TempDir.
  • HTTP: httptest.NewRecorder (in-process) vs NewServer (real port).
  • Confidence signals: -cover (statements only!), -race.
  • Performance: testing.B, auto-tuned b.N, b.ResetTimer, b.ReportAllocs, benchstat.
  • Robustness/docs: testing.F fuzz invariants; Example + // Output:.

💻 Code Examples

See the consolidated review file: Week 3 Review. This is a review day — no new snippet.

🏋️ Exercises / Practice

Exercise Status Link
Re-run the full week suite go test ./exercises/month-02/week-3/...
Coverage report for the week go test -cover ./exercises/month-02/week-3/...

🐛 Mistakes Made

  • None new — review day. Logged earlier-week traps into the spaced-repetition quiz.

❓ Open Questions

  • Carrying forward: go-cmp vs reflect.DeepEqual, TLS test servers, pprof for benchmark analysis.

🧠 Active Recall (answer without looking)

  1. Q: Which go test flags select tests, benchmarks, and fuzzing respectively?
    A

-run (regex selects tests/subtests), -bench (regex, runs benchmarks), -fuzz (one fuzz target into the mutation engine). Plain go test runs tests + examples + fuzz seeds, but not benchmarks. 2. Q: Give one invariant suitable for a fuzz test and one footgun in a benchmark.

A

Invariant: round-trip Reverse(Reverse(s)) == s. Benchmark footgun: dead-code elimination removing an unused result (sink it) or timing setup (use b.ResetTimer).

🪶 Feynman Reflection

This week turned "I hope it works" into "I can prove it works and know what it costs." Tests pin behavior, coverage shows blind spots, benchmarks quantify cost, and fuzzing attacks my assumptions with inputs I'd never think to write.

🕳️ Knowledge Gaps

  • pprof-driven optimization and go-cmp diffs — queued for later weeks.

✅ Summary

The full stdlib testing toolkit is now muscle memory: table tests, parallel subtests, httptest, coverage, benchmarks, fuzzing, and examples — no third-party deps required.

⏭️ Next Steps / Prep for Tomorrow

  • Week 4: profiling (pprof), go vet/staticcheck, modules & versioning, and build tooling.

Time spent Difficulty Confidence
90 min 🟦⬜⬜⬜⬜ 🟦🟦🟦🟦⬜

Suggested commit: docs(journal): week 3 review and recall (day 049)