我正在编写测试并尝试模拟IMyResponse接口。但它在嘲笑之后返回int。这是我的工作:
public interface IMyResponse extends Serializable {
// ...
Object getResponseObject();
}
private IMyResponse myResponse;
@Before
public void setUp(){
myResponse = mock(IMyResponse.class);
}
@Test
public void mockTest(){
// myResponse.getResponseObject() is 0
when(myResponse.getResponseObject()).thenReturn("value");
// myResponse.getResponseObject() is 46
}
我做错了什么?
答案 0 :(得分:1)
改变了mockito版本帮助(它是1.10):
androidTestImplementation 'org.mockito:mockito-android:2.15.0'