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
Feature: verify strict mocking in Mockito sense #334
Comments
@mikezx6r Is it possible to have this behavior on JUnit 4? |
@amatkivskiy I believe there's a Rule for JUnit4 that does the same thing. |
@oleksiyp I've looked into the Mockito Extension code. Basically, a Mock contains a list of Stubs. Each stub object has a 'called' flag. The Extension then just iterates through all mocks, and their stubs, and reports those that weren't 'called'. Don't know if that fits into Mockk's approach as I haven't looked at the code yet, but at least it's not very magical. |
Yes, seems possible to add. Although as a property for extension(if possible) |
Ok, I'll take a look at it. One issue I'm running into when I try to load the project into IntelliJ. In order to import, it appears the project requires an Android SDK be available, but as I don't develop Android apps, I don't have this on my machine. Are you able to let me know the easiest way to configure this so I can add it to the DEVELOPMENT.md, and setup my environment correctly? |
Have you checked https://github.com/mockk/mockk/wiki btw? It has some hints regarding debugging. I think you don't need Android SDK to open in IDEA. |
Forgot about the Wiki, but unfortunately that doesn't help. It's actually a Gradle build issue as I just tried building project from CLI. Here's what I get when I try to build. An issue building the Android agent module. So perhaps having an Android SDK is not optional anymore?
|
This should be relatively straightforward to implement as a flag in the MockKExtension |
This was fixed in v1.12.4. |
Expected Behavior
Using Mockito with JUnit Jupiter, adding the MockitoExtension enforces strict mocks. Mockito's definition is a bit different than Mockk's definition.
Mockito's definition of strict is that all defined expectations in a test are executed. This is automatically checked by the extension at the end of the test
Current Behavior
Mockk currently does not automatically report this when the extension is applied. I think attempting to do this manually is also not possible, or a lot of extra work.
I would like the extension to turn this feature on by default, or have Mockk provide an additional extension that can be applied that turns this feature on. JUnit Jupiter supports more than one extension, but I'm not sure if they can interact. I'm also not sure if Extensions can be 'configured' when they're applied, so not sure exactly how it can/should be implemented.
The text was updated successfully, but these errors were encountered: