🐹 Go (Golang)
Intermediate
What is table-driven testing in Go?
Answer
Table-driven testing is the idiomatic Go pattern for writing tests. You define a slice of structs, each representing one test case with inputs and expected outputs, then loop over them calling t.Run(tc.name, func(t *testing.T) { ... }) for each. This makes it trivial to add new test cases without duplicating test logic and clearly documents what each case tests. The testing package is built into Go's standard library — no framework needed. Run tests with go test ./... and get verbose output with -v. Table-driven tests also work seamlessly with the race detector.
Previous
What is reflection in Go and when should you use it?
Next
What does the -race flag do in go test?