Skip to content

Conversation

@seyfahni
Copy link
Contributor

@seyfahni seyfahni commented Oct 24, 2022

Why?

val stub = mock<SomeInterface>()

runBlocking {
  testWith(stub) // testing suspending code
}

stub.inOrder {
  verify().notSuspending()
  // this "worked" before my change, but didn't verify order
  verifyBlocking { suspending() }
  // instead one had to use runBlocking { verify().suspending() }
  // or val v = verify(); runBlocking { v.suspending() }
}

Changes:

  • Added interface KInOrder to allow extending mockito's InOrder interface:
    • defined verifyBlocking methods with similar definition to those in Verification
    • implemented interface with a decorator that takes a mockito InOrder and does blocking verification the same way as in Verification
  • Adjusted return types in Verification to provide KInOrder:
    • the implementation (KInOrderDecorator) is not internal so that the inline fun declaration continues working
  • Added methods to InOrderOnType that allow passing a VerificationMode.

Thank you for submitting a pull request! But first:

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix!

@TimvdLippe TimvdLippe merged commit c1122da into mockito:main Oct 25, 2022
@seyfahni seyfahni deleted the verify-blocking-in-order branch October 25, 2022 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants