在我断言的以下简单练习中,我期望 1,但得到 0。为什么我会看到这种行为?
public class MockitoTest {
POJO mockedPojo;
@Before
public void setup() {
mockedPojo = mock(POJO.class);
}
@Test
public void testIndifferentMethodInvocationOrder() {
int result1 = mockedPojo.getOne();
assertEquals(1, result1);
}
class POJO {
int count = 1;
int getOne() {
return count++;
}
int getTwo() {
return count++;
}
}
}