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

In a table-driven test, why is `tt := tt` (or `tc := tc`) commonly written at the top of the loop body before calling `t.Parallel()` in Go versions prior to 1.22?

for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got := Add(tt.a, tt.b) if got != tt.want { t.Errorf("got %d, want %d", got, tt.want) } }) }