Open GoogleCodeExporter opened 8 years ago
It seems for all assertions shouldMockThisCall in MockGateway.java:174 returns
true, except for the last one (after thenCallRealMethod() is called).
The putAdditionalState("DontMockNextCall", true) in MockRepository.java:238 is
called when callRealMethod is called on a non final system class
(MockitoMethodInvocationControl.java:239).
The Javadoc says this is needed to prevent infinite recursion. But maybe this
isn't the case for static methods???
Original comment by mob...@arnoldpistorius.com
on 20 Feb 2015 at 8:47
import android.content.Context; import android.text.format.DateFormat;
import junit.framework.TestCase;
import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner;
import java.text.SimpleDateFormat; import java.util.Calendar;
import static org.mockito.Matchers.any; import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.when;
/**
Created by Arnold Pistorius on 19-2-2015. */ @RunWith(PowerMockRunner.class) @PrepareForTest({Calendar.class, DateFormat.class}) public class StaticTest extends TestCase {
@Override protected void setUp() throws Exception { super.setUp();
}
@Test public void testTest() { // Check if DateFormat.getTimeFormat(...) returns a SimpleDateFormat assertTrue(DateFormat.getTimeFormat(mock(Context.class)) instanceof SimpleDateFormat); assertTrue(DateFormat.getTimeFormat(mock(Context.class)) instanceof SimpleDateFormat);
} }
Original issue reported on code.google.com by
mob...@arnoldpistorius.com
on 19 Feb 2015 at 3:22