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
Hi,
when stumbling over #2921 , I realized that Mockito will silently fail to inject
@Mockobjects 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@Mockfields with same type, and user will have to know which exactly).My suggestion would be to have a new error similar to
Reporter.cannotInjectDependencythatTerminalMockCandidateFilterthen should call ifmocks.size() > 1