This is a follow up issue for #27927 (comment), which discussed having an alternative mechanism to run tests from within TestMain. The proposal was the following:
func TestMain(m *testing.M) {
setupAll()
code := m.RunEach(func(t *testing.T) {
setup(t)
t.Run()
teardown(t)
})
teardownAll()
os.Exit(code)
}
Basically, testing.M should provide a way to iterate through the tests and allow code to be executed before and after each.
Originally posted by @mgwidmann in #27927 (comment)