You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
jfrantzius
pushed a commit
to jfrantzius/mockito
that referenced
this issue
Mar 14, 2023
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
thatTerminalMockCandidateFilter
then should call ifmocks.size() > 1
The text was updated successfully, but these errors were encountered: