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

Fix bad tests using mockery mocks without assertion #2659

Closed
qdm12 opened this issue Jul 8, 2022 · 1 comment
Closed

Fix bad tests using mockery mocks without assertion #2659

qdm12 opened this issue Jul 8, 2022 · 1 comment

Comments

@qdm12
Copy link
Contributor

qdm12 commented Jul 8, 2022

We have many tests still using mockery mocks, but never calling AssertExpectations(t) on the mock.
It means these tests pass, although the mocks are often plain wrong, and calling AssertExpectations(t) makes the whole test fail.

Since Mockery v2.12.x, there is now a mock constructor NewMockXXX generated per mock which registers AssertExpectations(t) in the testing t.Cleanup function, hence ensuring the mock is checked at the end of the test.

As of this writing, we use Mockery v2.14.x but we still don't use the new constructors. @qdm12 has been working on replacing all previous new(MockXXX) and &MockXXX to use the newer constructor in #2500 but that makes pretty much a lot of tests fail.

And no, replacing these mockery mocks with gomock mocks won't solve the problem either since the original mock configuration code is wrong. We could replace mockery with gomock mocks as we fix mock configs, but I'd say it would be easier to fix the mockery mocks config first then migrate.

@qdm12
Copy link
Contributor Author

qdm12 commented Sep 16, 2022

Fixed by #2500

@qdm12 qdm12 closed this as completed Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants