本文整理汇总了Java中org.mockito.internal.verification.VerificationModeFactory.times方法的典型用法代码示例。如果您正苦于以下问题:Java VerificationModeFactory.times方法的具体用法?Java VerificationModeFactory.times怎么用?Java VerificationModeFactory.times使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mockito.internal.verification.VerificationModeFactory
的用法示例。
在下文中一共展示了VerificationModeFactory.times方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: oneTimeOnly
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
public static VerificationMode oneTimeOnly() {
return VerificationModeFactory.times(1);
}
示例2: never
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
public VerificationMode never() {
return new Timeout(impl.getTreshhold(), impl.getTimeout(), VerificationModeFactory.times(0));
}
示例3: shouldNotAllowNegativeNumberOfInvocations
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
@Test
public void shouldNotAllowNegativeNumberOfInvocations() throws Exception {
try {
VerificationModeFactory.times(-50);
fail();
} catch (MockitoException e) {
assertEquals("Negative value is not allowed here", e.getMessage());
}
}
示例4: times
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
public VerificationMode times(int wantedNumberOfInvocations) {
return new Timeout(impl.getTreshhold(), impl.getTimeout(), VerificationModeFactory.times(wantedNumberOfInvocations));
}
示例5: inOrder
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
public Times inOrder() {
return VerificationModeFactory.times(times);
}
示例6: shouldStartVerificationAndPullVerificationMode
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
@Test
public void shouldStartVerificationAndPullVerificationMode() throws Exception {
assertNull(mockingProgress.pullVerificationMode());
VerificationMode mode = VerificationModeFactory.times(19);
mockingProgress.verificationStarted(mode);
assertSame(mode, mockingProgress.pullVerificationMode());
assertNull(mockingProgress.pullVerificationMode());
}
示例7: times
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
/**
* Allows verifying exact number of invocations. E.g:
* <pre>
* verify(mock, times(2)).someMethod("some arg");
* </pre>
*
* See examples in javadoc for {@link Mockito} class
*
* @param wantedNumberOfInvocations wanted number of invocations
*
* @return verification mode
*/
public static VerificationMode times(int wantedNumberOfInvocations) {
return VerificationModeFactory.times(wantedNumberOfInvocations);
}
示例8: timeout
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
/**
* Allows verifying with timeout. May be useful for testing in concurrent conditions.
* <p>
* It feels this feature should be used rarely - figure out a better way of testing your multi-threaded system
* <p>
* Not yet implemented to work with InOrder verification.
* <pre>
* //passes when someMethod() is called within given time span
* verify(mock, timeout(100)).someMethod();
* //above is an alias to:
* verify(mock, timeout(100).times(1)).someMethod();
*
* //passes when someMethod() is called *exactly* 2 times within given time span
* verify(mock, timeout(100).times(2)).someMethod();
*
* //passes when someMethod() is called *at lest* 2 times within given time span
* verify(mock, timeout(100).atLeast(2)).someMethod();
*
* //verifies someMethod() within given time span using given verification mode
* //useful only if you have your own custom verification modes.
* verify(mock, new Timeout(100, yourOwnVerificationMode)).someMethod();
* </pre>
*
* See examples in javadoc for {@link Mockito} class
*
* @param millis - time span in millis
*
* @return verification mode
*/
public static VerificationWithTimeout timeout(int millis) {
return new Timeout(millis, VerificationModeFactory.times(1));
}
示例9: times
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
/**
* Allows verifying exact number of invocations. E.g:
* <pre class="code"><code class="java">
* verify(mock, times(2)).someMethod("some arg");
* </code></pre>
*
* See examples in javadoc for {@link Mockito} class
*
* @param wantedNumberOfInvocations wanted number of invocations
*
* @return verification mode
*/
public static VerificationMode times(int wantedNumberOfInvocations) {
return VerificationModeFactory.times(wantedNumberOfInvocations);
}
示例10: timeout
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
/**
* Allows verifying with timeout. It causes a verify to wait for a specified period of time for a desired
* interaction rather than fails immediately if has not already happened. May be useful for testing in concurrent
* conditions.
* <p>
* This differs from {@link Mockito#after after()} in that after() will wait the full period, unless
* the final test result is known early (e.g. if a never() fails), whereas timeout() will stop early as soon
* as verification passes, producing different behaviour when used with times(2), for example, which can pass
* and then later fail. In that case, timeout would pass as soon as times(2) passes, whereas after would run until
* times(2) failed, and then fail.
* <p>
* It feels this feature should be used rarely - figure out a better way of testing your multi-threaded system
* <p>
* Not yet implemented to work with InOrder verification.
* <pre class="code"><code class="java">
* //passes when someMethod() is called within given time span
* verify(mock, timeout(100)).someMethod();
* //above is an alias to:
* verify(mock, timeout(100).times(1)).someMethod();
*
* //passes as soon as someMethod() has been called 2 times before the given timeout
* verify(mock, timeout(100).times(2)).someMethod();
*
* //equivalent: this also passes as soon as someMethod() has been called 2 times before the given timeout
* verify(mock, timeout(100).atLeast(2)).someMethod();
*
* //verifies someMethod() within given time span using given verification mode
* //useful only if you have your own custom verification modes.
* verify(mock, new Timeout(100, yourOwnVerificationMode)).someMethod();
* </code></pre>
*
* See examples in javadoc for {@link Mockito} class
*
* @param millis - time span in milliseconds
*
* @return verification mode
*/
public static VerificationWithTimeout timeout(int millis) {
return new Timeout(millis, VerificationModeFactory.times(1));
}
示例11: after
import org.mockito.internal.verification.VerificationModeFactory; //导入方法依赖的package包/类
/**
* Allows verifying over a given period. It causes a verify to wait for a specified period of time for a desired
* interaction rather than failing immediately if has not already happened. May be useful for testing in concurrent
* conditions.
* <p>
* This differs from {@link Mockito#timeout timeout()} in that after() will wait the full period, whereas timeout()
* will stop early as soon as verification passes, producing different behaviour when used with times(2), for example,
* which can pass and then later fail. In that case, timeout would pass as soon as times(2) passes, whereas after would
* run the full time, which point it will fail, as times(2) has failed.
* <p>
* It feels this feature should be used rarely - figure out a better way of testing your multi-threaded system
* <p>
* Not yet implemented to work with InOrder verification.
* <pre class="code"><code class="java">
* //passes after 100ms, if someMethod() has only been called once at that time.
* verify(mock, after(100)).someMethod();
* //above is an alias to:
* verify(mock, after(100).times(1)).someMethod();
*
* //passes if someMethod() is called <b>*exactly*</b> 2 times after the given timespan
* verify(mock, after(100).times(2)).someMethod();
*
* //passes if someMethod() has not been called after the given timespan
* verify(mock, after(100).never()).someMethod();
*
* //verifies someMethod() after a given time span using given verification mode
* //useful only if you have your own custom verification modes.
* verify(mock, new After(100, yourOwnVerificationMode)).someMethod();
* </code></pre>
*
* See examples in javadoc for {@link Mockito} class
*
* @param millis - time span in milliseconds
*
* @return verification mode
*/
public static VerificationAfterDelay after(int millis) {
return new After(millis, VerificationModeFactory.times(1));
}