Go theorytheory 0/50 · 0%
Toolchain · easy

19. Testing in Go

The testing package and table tests.

Tests live in _test.go files as func TestXxx(t *testing.T). Table-driven tests iterate over cases with t.Run subtests. Benchmarks use *testing.B, and the race detector (`go test -race`) finds concurrency bugs that are otherwise intermittent.

Check your understanding

  1. 1. Which flag enables the race detector?

  2. 2. Subtests are created with…