Created
January 7, 2019 14:38
-
-
Save bwplotka/a151fe43c9851ef092d29f912e7f8ca7 to your computer and use it in GitHub Desktop.
Table test initial boilerplate
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
for _, tcase := range []struct{ | |
}{ | |
{ | |
}, | |
}{ | |
if ok := t.Run("", func(t *testing.T) { | |
}); !ok { | |
return | |
} | |
} |
Thanks for sharing. I've added this to GoLand with a few changes.
testcases := []struct {
Name string
}{
{
Name: "foo",
},
{
Name: "bar",
},
{
Name: "baz",
},
{
Name: "foo",
},
}
for _, tc := range testcases {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
t.Parallel()
if tc.Name != "foo" {
t.Errorf("foo is expected test name: got %v", tc.Name)
}
})
}```
Thanks both, this is great!
I've iterated on it a bit
testcases := []struct {
Name string
}{
{
Name: "$NAME$",
},
}
for _, tc := range testcases {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
t.Parallel()
$END$
})
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Useful codegen configuration for Goland:
Double shift
-> "live templates" -> Go ->+
-> paste this code into template text