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

Within a table-driven test, one case is expected to make the function call t.Fatal-equivalent logic. Why is calling t.Fatalf from inside a helper goroutine in a subtest incorrect, and what is the right tool?

func TestThing(t *testing.T) { for _, tt := range cases { t.Run(tt.name, func(t *testing.T) { go func() { if !ok(tt) { t.Fatalf("bad") } // wrong }() }) } }