~/talk

Go Testing By Example

Talkat GopherCon AU 2023 · 2023-11-08..11-10· [go, testing]
name:Russ Cox
links:none on file
slides:none on file

Practical, concrete testing techniques for Go: 20 specific tips including table‑driven tests, using go test -coverprofile plus the uncover tool to find unexecuted lines, and writing exhaustive tests for all inputs up to size 10 backed by a slow reference implementation. Fixes include guarding against i+j overflow and proving it with a memory‑cheap test using a huge slice of empty strings. Use file‑based tests, a simple archive format Texar, updatable golden files (‑update flag), script‑based command tests, and CI deploy gating for go.dev.

AI-written summary · about

  1. 0:00Why write tests
  2. 3:55Software engineering tests
  3. 6:02Make tests easy to add
  4. 7:27Use test coverage
  5. 9:14Coverage vs thought
  6. 10:59Write exhaustive tests
  7. 13:54Separate test cases
  8. 14:15Look for special cases
  9. 15:18Always add a test
  10. 17:06Test data in tables
  11. 19:35Test cases in files
  12. 20:18Compare implementations
  13. 22:25Make failures readable
  14. 24:11Update test answers
  15. 24:54Texar for multifile tests
  16. 28:51Annotate existing formats
  17. 30:16Write custom parsers
  18. 32:45High-quality Go tests
  19. 34:10Scripts as test cases
  20. 37:17Aim for continuous deployment
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.