Created
May 29, 2020 16:00
-
-
Save nullren/2dc79c167195a964118919e28ba679bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example | |
type testcase struct { | |
name string | |
... | |
} | |
func TestTheTestcases(t *testing.T) { | |
testcases := []*testcase{...} | |
for _, test := range testcases { | |
// this is needed to keep `test` in scope. are there alternatives to this pattern? | |
test := test | |
t.Run(test.name, func(t *testing.T) { | |
... | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh, this is especially for when test cases are run in parallel. ie, from the docs https://godoc.org/testing