Curriculum Idioms & ecosystem Testing
Testing
Go has a testing package in the standard library. Tests live next to code in _test.go files. The pattern is table-driven: a slice of (name, input, want) tuples plus t.Run(name, ...) for subtests. No assertion library required — if got != want { t.Errorf(...) } is the whole vocabulary.
Exercises
9 ready
01
pick one
Pick the file naming convention that the Go toolchain
02
pick one
Pick the IDIOMATIC signature for a top-level Go test
03
pick one
Pick the IDIOMATIC failure-reporting line inside a Go
04
fill blanks
Type the prefix that every top-level test function name
05
fill blanks
Type the method on *testing.T that reports a failure
06
type one line
Yaegi can't import the testing package, so this exercise
07
type one line
Write the t.Errorf call inside an if-block that triggers
08
write a program
Demonstrate the table-driven test pattern — Go's
09
write a program
Theme 7.4 capstone — table-driven test with a deliberate