我正在尝试模拟这种方法,该方法利用了此类中已声明的私有字段。但是,当方法someMethod显然接受了两个我已经考虑过的字符串时,我不确定为什么会在Mockito.doNothing()行上收到AssertionError。
错误:
java.lang.AssertionError
代码:
class Main{
private Person person;
...
public void testMethod() {
person.someMethod("string1", "string2");
...
}
}
class Person{
public void someMethod(String a, String b){
... do something ...
}
}
class TestMain(){
@InjectMocks
private Main testee;
@Mock
private Person person;
@Test
testTestMethod(){
Mockito.doNothing().when(person).someMethod(any(String.class), any(String.class));
}
}