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

Remove deprecated verifyZeroInteractions #447

Merged
merged 1 commit into from
Oct 8, 2021

Conversation

rashadsookram
Copy link
Contributor

Fixes #446.

I just removed the method for now, but if it's preferred to keep it around and call through to verifyNoMoreInteractions instead, let me know and I can update the PR.


Thank you for submitting a pull request! But first:

  • Can you back your code up with tests?
    • there were no tests for verifyZeroInteractions as far as I can tell
  • Keep your commits clean: squash your commits if necessary.

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.

It might be a good idea to also bump mockito-core to 4.0.0 in the same commit, so that we can publish that as-is. Do you mind adding that?

@rashadsookram
Copy link
Contributor Author

@TimvdLippe I bumped mockito-core in the mockito-kotlin module, but left it as-is in the tests module. Should it be updated there too? It looks like it's on an even older version:

compile "org.mockito:mockito-core:2.23.0"

@TimvdLippe
Copy link
Contributor

@rashadsookram Oh that's strange. Yes we should update the version in both. They should have been using the same version from the get-go. Maybe we can remove that line from the test gradle file altogether, as it will use the artifact inherited from the main bundle?

Comment on lines -185 to +190
verify(out).println("methods.stringResult();")
argumentCaptor<DescribedInvocation>().apply {
verify(out).println(capture())
expect(lastValue.toString()).toBe("methods.stringResult();")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In Mockito 2.23.0, println used to be called with a string, but in 4.0.0 it's called with a DescribedInvocation directly.

What do you think about checking the value like this? It didn't seem like it would be simple to create an InterceptedInvocation to use for the test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that seems good to me 👍

@rashadsookram
Copy link
Contributor Author

@TimvdLippe I updated the version in the tests module, but it didn't seem like removing the version from there would work. When I tried to remove it, the tests failed with NoClassDefFoundErrors since Mockito wasn't on the classpath. This makes sense to me, since the tests project only depends on the Mockito-Kotlin jar, which doesn't contain the classes from Mockito.

An alternative would be to make something like the dependencies.gradle file in Mockito, so that the versions could be shared between the different Gradle subprojects.

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.

This works for me, thanks!

Comment on lines -185 to +190
verify(out).println("methods.stringResult();")
argumentCaptor<DescribedInvocation>().apply {
verify(out).println(capture())
expect(lastValue.toString()).toBe("methods.stringResult();")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that seems good to me 👍

@TimvdLippe TimvdLippe merged commit 7f1d094 into mockito:main Oct 8, 2021
@ratepay-sstein
Copy link

When can we expect a release of mockito-kotlin, which is compatible with Mockito 4?

@TimvdLippe
Copy link
Contributor

@ratepay-sstein I had pushed the 4.0.0 tag yesterday, but it seems like it wasn't running the release procedure. #448 should fix that, thanks for letting us know!

@TimvdLippe
Copy link
Contributor

@ratepay-sstein
Copy link

@TimvdLippe Wow, that was fast :-) I haven't migrated our full source yet, but it seems to work.

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.

Remove verifyZeroInteractions?
3 participants