Skip to content

NotAMockException when using spy() on interface with a @Primary or @Secondary #26

@rbygrave

Description

@rbygrave
  @Test
  public void withMockitoSpy_whenPrimary_expect_spyUsed() {

    try (BeanContext context = new BootContext()
      .withSpy(PEmailer.class) // has a primary
      .load()) {

      UserOfPEmailer user = context.getBean(UserOfPEmailer.class);
      PEmailer emailer = context.getBean(PEmailer.class);

      user.email();
      verify(emailer).email();
    }
  }

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions