Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: testing: per-test setup and teardown support #68354

Closed
PapaCharlie opened this issue Jul 9, 2024 · 2 comments
Closed

proposal: testing: per-test setup and teardown support #68354

PapaCharlie opened this issue Jul 9, 2024 · 2 comments
Labels
Milestone

Comments

@PapaCharlie
Copy link

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)

@gopherbot gopherbot added this to the Proposal milestone Jul 9, 2024
@gabyhelp
Copy link

gabyhelp commented Jul 9, 2024

@seankhliao
Copy link
Member

Duplicate of #53701

@seankhliao seankhliao marked this as a duplicate of #53701 Jul 9, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants