Annotation Type MockitoBean
Replaces every bean of the field's type with a Mockito mock, and injects it:
@MockitoBean Mailer mailer;
@Test
void signupSendsMail() throws Exception {
mvc.perform(post("/signup").content("ada@example.com"));
verify(mailer).send(eq("ada@example.com"), anyString());
}
The mock is reset after each test. It needs Mockito on the test classpath and
runs only on the JVM: a mocking library builds classes at run time, which a
translated binary cannot, so a compiled test run reports these classes as
skipped. A TestConfiguration with a @Primary fake works in both.