Search in sources :

Example 31 with MockitoSession

use of org.mockito.MockitoSession in project dexmaker by linkedin.

the class MockStatic method doReturnMockWithTwoClasses.

@Test
public void doReturnMockWithTwoClasses() throws Exception {
    MockitoSession session = mockitoSession().mockStatic(SuperClass.class).mockStatic(SubClass.class).startMocking();
    try {
        doReturn("fakeB").when(SuperClass::returnB);
        assertEquals("fakeB", SuperClass.returnB());
        doReturn("fakeD").when(() -> SubClass.record("test"));
        assertEquals("fakeD", SubClass.record("test"));
    } finally {
        session.finishMocking();
    }
}
Also used : MockitoSession(org.mockito.MockitoSession) Test(org.junit.Test)

Aggregations

MockitoSession (org.mockito.MockitoSession)31 Test (org.junit.Test)30 StaticInOrder (com.android.dx.mockito.inline.extended.StaticInOrder)3 ContentResolver (android.content.ContentResolver)2 ArrayList (java.util.ArrayList)1 MockingDetails (org.mockito.MockingDetails)1 MissingMethodInvocationException (org.mockito.exceptions.misusing.MissingMethodInvocationException)1 UnnecessaryStubbingException (org.mockito.exceptions.misusing.UnnecessaryStubbingException)1 VerificationInOrderFailure (org.mockito.exceptions.verification.VerificationInOrderFailure)1 MockitoSessionLoggerAdapter (org.mockito.internal.session.MockitoSessionLoggerAdapter)1 Strictness (org.mockito.quality.Strictness)1 MockitoSessionLogger (org.mockito.session.MockitoSessionLogger)1