Canonical guidance

Use when

Avoid

Preferred pattern

for _, tc := range tests {
	t.Run(tc.name, func(t *testing.T) {
		got := Parse(tc.in)
		if got != tc.want {
			t.Fatalf("Parse(%q) = %q, want %q", tc.in, got, tc.want)
		}
	})
}

Anti-pattern

Explanation: This anti-pattern is tempting because terse assertions look clean, but weak diagnostics slow down debugging and make regressions harder to understand.

Why

Related pages

Sources