我试图让Mockito中的verify
方法正常工作。我有以下测试:Mockito验证不失败
@Test
public void testShouldFail()
{
String string = mock(String.class);
string.length();
verify(string, times(100)).length();
}
此测试应该失败,但它通过。有人知道为什么吗?我使用Mockito错了吗?
更新
下面是不会失败的另一个例子:
private interface Bar
{
public void foo();
}
@Test
public void testShouldFail()
{
Bar bar = mock(Bar.class);
bar.foo();
verify(bar, times(100)).foo();
}
你是第二个例子,当测试失败时,你能否提供更多的细节? – 2012-03-04 14:34:53