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

Introduce verifyCount DSL #1234

Merged
merged 8 commits into from Mar 20, 2024
Merged

Conversation

T45K
Copy link
Contributor

@T45K T45K commented Mar 13, 2024

this is draft implementation
i'd like maintainers to check such points

  • API.kt and MockK.kt are implemented appropriately
  • tests are enough
  • some changes i added as refactoring are acceptable

thank you


Overview

based on this discussion, i added verifyCount DSL to make verifying call count easy

Syntax

val mock = mockk<ClassUnderTest>()

...

verifyCount {
  1 * { mock.method() } // this is same as verify(exactly = 1) { mock.method() }
  0 * { mock.method() } // this is same as verify(exactly = 0) { mock.method() }
  (0..5) * { mock.method() } // this is same as verify(atLeast = 0, atMost = 5) { mock.method() }
}

this is inspired by Spock and Mockito-Kotlin

@Raibaz
Copy link
Collaborator

Raibaz commented Mar 14, 2024

Overall LGTM, two observations:

  • Can you please run the :mockk-dsl:apiDump gradle task to update the API definitions file?
  • Would you also be able to add documentation for this in the README.md file?

Thanks a lot for putting this together, this looks really cool!

@T45K
Copy link
Contributor Author

T45K commented Mar 15, 2024

@Raibaz
thank you for checking!
i updated where you pointed out.

could you check whether the doc is OK?

@T45K T45K marked this pull request as ready for review March 15, 2024 08:48
@T45K
Copy link
Contributor Author

T45K commented Mar 15, 2024

hmm, do i need something to do to pass all CI?

ah, i found that i need to execute not only ./gradlew :mockk-dsl:apiDump but also ./gradlew apiDump

@T45K
Copy link
Contributor Author

T45K commented Mar 20, 2024

@Raibaz
could you check again? 🙏

@Raibaz Raibaz merged commit fe0e306 into mockk:master Mar 20, 2024
11 checks passed
@Raibaz
Copy link
Collaborator

Raibaz commented Mar 20, 2024

Looks great, thanks a lot! 🙏

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