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

Do not share state in test functions #71

Open
shibumi opened this issue Aug 20, 2020 · 0 comments
Open

Do not share state in test functions #71

shibumi opened this issue Aug 20, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@shibumi
Copy link
Collaborator

shibumi commented Aug 20, 2020

Description of issue or feature request:
Right now, we call a TestMain method to create a test directory, copy over all our test files and work on this directory for each test. This can be dangerous, because tests are sharing states. Just imagine a test, that does not clean up properly or that alters one of our test files. The solution is to create a helper function, that creates a separate test directory for each function.
The disadvantage would be to have to call that function in every test, the benefit would be an isolated test environment for each test. We can make use of T.TempDir for this. T.TempDir is new in Go 1.15 and will cleanup the test directory automatically, when exiting the function.

Current behavior:
One big test directory for all tests

Expected behavior:
We should create an isolated test directory for each step.

@shibumi shibumi added the enhancement New feature or request label Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant