Android - 测试吐司时出错

时间:2015-08-03 16:36:16

标签: android mockito

我使用mockito进行了测试verifies如果调用Toast。 当我只运行我的班级测试时,IT工作。

Toast toast = mock(Toast.class);
verify(toast, times(1)).makeText(Robolectric.application, R.string.no_internet_connection, 1).show();

但是当我运行所有测试时,它会显示错误。我不明白为什么。 当我删除该行并运行测试时,Log不会向我显示任何错误。

控制台:

Missing method call for verify(mock) here:
-> at co.m.....(TestNetworkUtil.java:131)

Example of correct verification:
    verify(mock).doSomething()

Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.

org.mockito.exceptions.misusing.UnfinishedVerificationException: 
Missing method call for verify(mock) here:
-> at co.m...

0 个答案:

没有答案