Technical Entry Level

How do you approach testing in Go? Explain table-driven tests and when you use testify versus the standard library.

Quick Tip

Describe the pattern: "I use table-driven tests with t.Run for named subtests. Standard library assertions are clear enough for most cases. I add testify when I need generated mocks or complex assertion chains."

What good answers include

Table-driven tests define test cases as a slice of structs with inputs and expected outputs, then loop through them. This reduces boilerplate and makes adding cases trivial. Standard library testing package is sufficient for most needs with t.Run for subtests, t.Parallel for concurrent tests, and t.Helper for clean stack traces. Testify adds assertion helpers and mocks. Strong candidates prefer the standard library for simplicity and reach for testify only when assertion readability or mock generation adds genuine value.

What interviewers are looking for

Tests professional Go development practices. Candidates who do not know table-driven tests are likely inexperienced with Go. Those who immediately reach for heavy frameworks may not appreciate Go simplicity.

← All Go questions