-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
testing: shutdown hook? #8159
Labels
Milestone
Comments
I think we need a testing.Atexit to do the clean work. CL13729043 has some discuss about the testing.Atexit. https://golang.org/cl/13729043/ |
I don't see Atexit happening. It's too awful. issue #8202 describes an alternative. |
We could add some more conventions: If a function called SetUp exists then it runs before any of the tests. If a function called TearDown exists then it runs after all the tests have run. More generally, we could have: If a function starts with SetUp(.*) and takes *testing.T then it will be run before any of the tests that start with Test\1 are run. If a function starts with TearDown(.*) and takes a *testing.T then it will be run after all of the tests that start with Test\1 are run. This can lead me to write something like: func SetupCaseFoo(t... func TestCaseFooBar(t... func TestCaseFooBlee(t.. func TearDownCase(t.. etc. If the concern is that there might already be functions with such names and argument types then a new type could be introduced that must be the argument that is an alias for testing.T (or that is more specifically suitable for setup and teardown functions). |
Status changed to Duplicate. Merged into issue #8202. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: