org.mockito.Mockito.calls()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(1.0k)|赞(0)|评价(0)|浏览(264)

本文整理了Java中org.mockito.Mockito.calls()方法的一些代码示例,展示了Mockito.calls()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mockito.calls()方法的具体详情如下:
包路径:org.mockito.Mockito
类名称:Mockito
方法名:calls

Mockito.calls介绍

[英]Allows non-greedy verification in order. For example

inOrder.verify( mock, calls( 2 )).someMethod( "some arg" );
  • will not fail if the method is called 3 times, unlike times( 2 )
  • will not mark the third invocation as verified, unlike atLeast( 2 )
    This verification mode can only be used with in order verification.
    [中]允许按顺序进行非贪婪验证。例如
inOrder.verify( mock, calls( 2 )).someMethod( "some arg" );

*如果方法被调用3次,则不会失败,这与调用次数(2)不同
*不会将第三次调用标记为已验证,至少与(2)不同
此验证模式只能用于顺序验证。

代码示例

代码示例来源:origin: info.solidsoft.mockito/mockito-java8

/**
 * Delegates call to {@link Mockito#calls(int)}.
 */
default VerificationMode calls(int wantedNumberOfInvocations){
  return Mockito.calls(wantedNumberOfInvocations);
}

代码示例来源:origin: szpak/mockito-java8

/**
 * Delegates call to {@link Mockito#calls(int)}.
 */
default VerificationMode calls(int wantedNumberOfInvocations){
  return Mockito.calls(wantedNumberOfInvocations);
}

相关文章