-
Notifications
You must be signed in to change notification settings - Fork 237
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
Dynamically create mock instance. #46
Comments
I am not sure what you're asking. When @mocked is used, any number of additional mocked instances can be created simply be instantiating them with a "new TheMockedClass(...)" expression. You can also use the "NonStrictExpectations(Object...)" constructor to turn non-mocked instances to mocked ones. If your use case is different, I would need to see an example so I can understand it. |
When @mocked are used, we can't create new instances of real object. What I was asking is something like dynamically create @Injectable instances.
This function is handy in the case we parameterize the test functions. The "NonStrictExpectations(Object...)" can create partial mock why I want fully mocked object (this should be simpler, so I don't see why I can't do it.) |
Well, I've never seen a realistic situation where this would be useful. If that changes, the API may be changed to accomodate it. |
….plugins-maven-surefire-plugin-3.x Update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.0.0-M7
Hi,
I know the @mocked is great, but is there any way we can create mock manually and use them in Expectations API? I mean I want to have a function to generate mock objects on demand while still able to create non-mocked objects. We have the @Injectable, why can't we create mock objects on demand?
The text was updated successfully, but these errors were encountered: