Your Go table test passes, but not for the reason you think

go dev.to

This is the single most reproduced bug in Go test suites, and it is green the whole time it is wrong. func TestValidate(t *testing.T) { cases := []struct { name string in string want bool }{ {"empty", "", false}, {"valid", "abc", true}, {"too long", strings.Repeat("x", 300), false}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { t.Parallel() if got := Validate(tc.in); got != tc

Read Full Tutorial open_in_new
arrow_back Back to Tutorials