Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

@Documented @Retention(RUNTIME) @Target({FIELD})

public @interface 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("[email protected]"));
    verify(mailer).send(eq("[email protected]"), 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.