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
Mockk does not have expectations #610
Comments
Hi, thanks a lot for submitting this and for the detailed explanation. Could it be that this is, actually, a duplicate of #334? If I understand correctly, the behavior you would like to see is the same described in that issue. |
@Raibaz Yeah, I'd say #334 is a similar ask, but I would prefer adding a new concept/keyword "expect" (or, in case "expect" is a reserved keyword or something, "expectation" or whatever), rather than mess with the existing "every" keyword and it's behavior through config as suggested in #334. This is perhaps mostly just personal taste - I personally have an intuitive dislike of that kind of magic config that changes behavior of things in non-obvious ways. |
Yep I agree it's mostly about personal taste. In my opinion having a different keyword for stubbed behaviors that need to be executed for the test to pass may lead to users mixing I think it would be clearer to declare a test class as using strict mode, or maybe even being able to configure mockk to always use strict mode by default with a global setting. Closing this for now, then. |
SUMMARY
Mockk does not have expectations, so the user ends up having to write both every and verify statements in many tests.
LONGER VERSION
Imagine this class
and this test (this is just an example to illustrate a point, let's not worry about how good or bad of a test this is)
everything passes, great. Now imagine someone comes in and comments out one of the inserts
the test
will still (undesirably) pass - verify statements need to be added in order to make it fail.
= Mockk doesn't consider every statements to be expectations, and doesn't fail if specced every statements never get called. Having to always add both every statements and verify statements to so many tests is kind of redundant. Other frameworks do have expectations - it would be nice if expectations were added to Mock as well.
eg
which fails when
The text was updated successfully, but these errors were encountered: