testify
testify copied to clipboard
Allow to set a name for Suite
Hi,
Maybe I'm wrong with it but it would be very nice to have a possibility to change or decorate the suite name. If I see it correctly suite name is automatically selecting the function name. For example, I have a Test struct which is used several times with different attribute content.
golden.go
type TemplateGoldenTest struct {
suite.Suite
Release string
Namespace string
}
func (s *TemplateGoldenTest) TestContainerGoldenTestDefaults() {
...
}
chart_test.go
for _, template := range listTemplates {
suite.Run(t, &golden.TemplateGoldenTest{
Release: template.name,
Namespace: template.namespace,
})
}
In test output its hard to differentiate between the different tests.
I appreciate any feedback. Thanks.
suite.Run
is a top-level call for test. So it have the same name as Test-function.
If you want to run several suites inside one test just wrap it with t.Run
with suitable names. Like this:
for _, template := range listTemplates {
t.Run(template.name, func(t *testing.T) {
suite.Run(t, &golden.TemplateGoldenTest{
Release: template.name,
Namespace: template.namespace,
})
})
}
The workaround suggested above seems good enough.