Skip to content

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

@jfrantzius

Description

@jfrantzius

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions