Skip to content

Commit

Permalink
fix atMost + timeout verify
Browse files Browse the repository at this point in the history
this is addressed to fix mockk#1169
  • Loading branch information
dsame committed Nov 21, 2023
1 parent fa0fb5a commit 3dc1034
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ class TimeoutVerifier(
val stubs = verificationSequence.allStubs(stubRepo)

val session = stubRepo.openRecordCallAwaitSession(stubs, params.timeout)
val startTime = System.currentTimeMillis()
try {
while (true) {
val result = verifierChain.verify(verificationSequence, params)
if (params.inverse != result.matches) {
// With atMost set the reaching expected result does not mean test passed
// - it can fail till the end of the timeout
if (params.inverse != result.matches &&
(params.max != Int.MAX_VALUE && (System.currentTimeMillis() - startTime < params.timeout))) {
return result // passed
}
if (!session.wait()) {
Expand Down

0 comments on commit 3dc1034

Please sign in to comment.