Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ease verify inOrder for suspending functions #464

Merged
merged 1 commit into from Oct 25, 2022

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
6 checks passed
@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.

None yet

2 participants