Canonical guidance

Use when

Avoid

Preferred pattern

t.Run("invalid input", func(t *testing.T) {
	// ...
})

Anti-pattern

Explanation: This anti-pattern is common because subtests are easy to nest, but excessive nesting obscures which behavior actually failed.

Why

Related pages

Sources