File tree Expand file tree Collapse file tree 1 file changed +1
-26
lines changed Expand file tree Collapse file tree 1 file changed +1
-26
lines changed Original file line number Diff line number Diff line change @@ -3898,32 +3898,7 @@ for multiple inputs/outputs to a system.
38983898
38993899#### Parallel Tests
39003900
3901- Parallel tests, like some specialized loops (for example, those that spawn
3902- goroutines or capture references as part of the loop body),
3903- must take care to explicitly assign loop variables within the loop's scope to
3904- ensure that they hold the expected values.
3905-
3906- ``` go
3907- tests := []struct {
3908- give string
3909- // ...
3910- }{
3911- // ...
3912- }
3913-
3914- for _ , tt := range tests {
3915- tt := tt // for t.Parallel
3916- t.Run (tt.give , func (t *testing.T ) {
3917- t.Parallel ()
3918- // ...
3919- })
3920- }
3921- ```
3922-
3923- In the example above, we must declare a ` tt ` variable scoped to the loop
3924- iteration because of the use of ` t.Parallel() ` below.
3925- If we do not do that, most or all tests will receive an unexpected value for
3926- ` tt ` , or a value that changes as they're running.
3901+ Run ` t.Parallel() ` to improve the performance of your test cases.
39273902
39283903<!-- TODO: Explain how to use _test packages. -->
39293904
You can’t perform that action at this time.
0 commit comments