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

In this Go 1.21 table-driven test, all parallel subtests unexpectedly run against the same case. What is the fix... and is it still needed?

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