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

Feature suggestion: TerminalMockCandidateFilter should report error when more than one candidate left #2934

Closed
jfrantzius opened this issue Mar 9, 2023 · 0 comments · Fixed by #2942

Comments

@jfrantzius
Copy link
Contributor

Hi,
when stumbling over #2921 , I realized that Mockito will silently fail to inject @Mock objects when there is more than one candidate. Usually, DI containers will throw an exception in that case, otherwise the user first has to understand what went wrong (no injection happened), and then start wondering why it failed (e.g. multiple @Mock fields with same type, and user will have to know which exactly).

My suggestion would be to have a new error similar to Reporter.cannotInjectDependency that TerminalMockCandidateFilter then should call if mocks.size() > 1

jfrantzius pushed a commit to jfrantzius/mockito that referenced this issue Mar 14, 2023
jfrantzius pushed a commit to jfrantzius/mockito that referenced this issue Mar 14, 2023
TimvdLippe pushed a commit that referenced this issue Mar 18, 2023
…ld (#2942)

Fixes #2934

Co-authored-by: Jörg von Frantzius <joerg.frantzius@aperto.com>
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

Successfully merging a pull request may close this issue.

1 participant