-
Notifications
You must be signed in to change notification settings - Fork 107
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
How to use Gock with Parallel tests #117
Comments
@sazzer, one workaround you can do is to create separate gock request instances for each test case and flush it off when the test case is executed. eg.
`
}` |
Doesn't work for me... I just disabled the t.Parrallel() for the few cases I had... |
I'll openly admit I'm not the most proficient Go user. As such, I make heavy use of tools like golangci-lint to validate my code.
One thing this constantly flags up is when I forget
t.Parallel()
in my tests. However, I've also noticed that if I am using this then my gock-based tests fail.For example:
This test file will sometimes pass, and will sometimes fail. And that's not surprising, because Gock has a bunch of static state that's shared between tests, and the tests are running in parallel.
Obviously removing
t.Parallel()
will make this work, but that seems a shame. I've also seen a suggestion of writing aTestMain()
function that does all of the Gock work, but that also seems overly complicated for what's needed.Are there any other recommended ways of doing tests like this?
Cheers
The text was updated successfully, but these errors were encountered: