-
Notifications
You must be signed in to change notification settings - Fork 461
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
shouldIgnoreMissing() not working on instance mocks #177
Comments
Are you proposing to throw an exception in case if call is made to a method, that is undefined in mocked class? If so, then this can be already done via global configuration: https://github.com/padraic/mockery#mockery-global-configuration |
@aik099 I think i did not clearly make my point. I think, a mock which has been created using |
I think for consistency, you're probably right, but it's not drastically broken now, so I'll tag this as a feature request and I'll try and get on to it at some point. |
I also got to this... First time trying mocks in unit tests and I found the behaviour quite inconsistent, since the documentation tells about partial mocks and instance mocks, but it's not said they don't work together. It does look like something is broken since the methods |
Sounds confusing, but it's because of internals. When you do a Once the Calling Calling If you want the flag set to Obviously this is far from perfect. One idea I have is to have a global configuration for this, I have a proof of concept in this commit robertbasic@32d70b7 Thoughts? /ping @padraic |
@davedevelopment Thoughts? See how well I can delegate? 😆 |
When you do a |
Hm I was looking in there, but didn't see anything useful. Will try again that then. |
This is a complete hack and I haven't tested it, but should work in theory
|
@davedevelopment pull request was merged, ticket can be closed? |
shouldIgnoreMissing()
does not work on mock objects created using instance mocks.leads to
BadMethodCallException: Method ::doSomething() does not exist on this mock object
I think it this function would be pretty useful, especially for instance mock objects. Also it looks a little inconsistent, since one can set expectations using
shouldReceive
on all instances, butshouldIgnoreMissing
only affects the current mock object.The text was updated successfully, but these errors were encountered: