/** * Delegates call to {@link Mockito#after(long)}. */ default VerificationAfterDelay after(long millis) { return Mockito.after(millis); }
/** * Delegate call to public static org.mockito.verification.VerificationAfterDelay org.mockito.Mockito.after(long) * {@link org.mockito.Mockito#after(long)} */ default VerificationAfterDelay after(long millis) { return Mockito.after(millis); }
/** * Delegate call to public static org.mockito.verification.VerificationAfterDelay org.mockito.Mockito.after(long) * {@link org.mockito.Mockito#after(long)} */ default VerificationAfterDelay after(long millis) { return org.mockito.Mockito.after(millis); }
/** * 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)); }