~/talk

How NOT to Write a Test in Go

Talkat GopherCon UK 2023 · 2023-08-16..08-18· [go, testing]
slides:none on file

Covers concrete anti-patterns and fixes: replaces duplicated checks with table-driven tests, demonstrates the t.Parallel loop-variable bug and its fix (copy loop var), recommends t.Cleanup over defer for test teardown, shows enabling the race detector with go test -race, mentions testify suites for complex setup, uses go test flags (shuffle seed, benchmem, -count) and gives a minimal GitHub Actions YAML to run go build and go test on push.

AI-written summary · about

  1. 0:00Testing in Go
  2. 2:30Why test Go code
  3. 7:32Avoid test writing mistakes
  4. 12:11Table-driven tests
  5. 18:12Detecting data races
  6. 20:22Mocking in Go
  7. 24:35Random test order
  8. 26:01Writing benchmarks
  9. 30:15GitHub Actions tests
  10. 31:41Key takeaways
~/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.