Mock.verify()

Verifies certain behavior happened at least once / exact number of times / never. E.g:


   verify(mock, times(5)).someMethod("was called five times");

   verify(mock, atLeast(2)).someMethod("was called at least two times");

   //you can use flexible argument matchers, e.g:
   verify(mock, atLeastOnce()).someMethod(anyString());
 
times(1) is the default and can be omitted

Arguments passed are compared using equals() method. Read about ArgumentCaptor or ArgumentMatcher to find out other ways of matching / asserting arguments passed.(使用equals()方法比较传递的参数。 阅读有关ArgumentCaptor或ArgumentMatcher的信息,以找出其他传递匹配/断言参数的方法。)

Type Parameters:
Parameters:
mock to be verified
mode times(x), atLeastOnce() or never()
Returns:
mock object itself

你可能感兴趣的:(Test)