简体   繁体   中英

Mockito Instrumentation Test

I am trying to use Mockito to perform Instrumentation Testing in Android.

@RunWith(MockitoJUnitRunner.class)
public class LoginActivityTest {

    @Mock
    private FirebaseDatabase firebaseDatabase;
    @Mock
    private FirebaseAuth firebaseAuth;
    @Mock
    private LoginView view;

    @InjectMocks
    private LoginActivityPresenter presenter;

    @Test
    public void validateInput() {
        Assert.assertEquals(2 + 2, 4);
    }
}

After running the validateInput test, I am seeing "No tests were found" and "Empty test suite." Would you be able to tell me what I am doing wrong? It works perfectly if I write the same code for a typical unit test class.

Note: I am just experimenting with Mockito and UI testing. I acknowledge that I could test the presenter only.

You cannot simply run Mockito tests on Android, you need to activate an Android-compatible mock maker for this. This feature was added recently as the mockito-android artifact. It is documented in the Mockito class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM