Table-driven tests

A table-driven test stores multiple test cases as data and runs the same test logic for each case. This reduces repeated code and makes it easier to cover normal, boundary, and invalid inputs consistently.

Learn this concept

Lesson 1.12 · Go testing: testing.T, subtests and table-driven tests

Used in exercises

Exercise 1.15 · Table-driven tests with a fake clock, plus one race test Exercise 7.16 · Filesystem secret scanner
Prerequisite conceptsGo testingGo slicesGo structs