Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumGotable-driven testsSingle-choice MCQ

In a table-driven test, each subtest is launched in a closure inside a loop with `t.Run(tc.name, func(t *testing.T) { t.Parallel(); ... })`. Across Go versions, what is the subtle bug this can introduce when the test cases come from a `for _, tc := range cases` loop?

for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { t.Parallel() if got := Add(tc.a, tc.b); got != tc.want { t.Errorf("got %d want %d", got, tc.want) } }) }