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

Avoid seeding global random number generator in tests #189

Closed
fxamacker opened this issue Oct 25, 2021 · 0 comments · Fixed by #204
Closed

Avoid seeding global random number generator in tests #189

fxamacker opened this issue Oct 25, 2021 · 0 comments · Fixed by #204
Assignees
Labels

Comments

@fxamacker
Copy link
Member

Issue To Be Solved

Tests are seeding the global random number generator. However, seeding the global random number generator is not recommended since its global state can be changed by other packages at runtime.

Suggested Solution

Avoid using the global random number generator for tests, especially if randomized tests print out their nondeterministic seed to allow reproducing test failures.

Use rand.New to create, seed, and use non-global (private) random number generators. This will allow control over determinism vs non-determinism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant