gojuno / minimock

Powerful mock generation tool for Go programming language
MIT License
574 stars 38 forks source link

Add parallel test scenario in README #65

Closed CyganFx closed 1 year ago

CyganFx commented 1 year ago

Hi, when one executes tests in parallel with t.Parallel(), and does something like: defer mockController.Finish() (similar with Wait(<duration>) ) controller fails to recognize that some of mocks' Expect/Return and other patterns are not used. Without parallel tests, there would be error like: 'Expected to call .GetMock ...'

To fix that, you need to use Cleanup method of testing.T and inside it call whether Finish or Wait.

Could be implemented like in this issue https://github.com/gojuno/minimock/issues/62

I think it'd be useful to add it in README, as go official docs aren't much informative

hexdigest commented 6 months ago

Hey @CyganFx

I think the problem here is that you re-use controller for every t.Run instead of creating a new controller for each t.Run which is the correct way to do it.

But I agree that this should be mentioned in the docs.