mockito-collections icon indicating copy to clipboard operation
mockito-collections copied to clipboard

@Spy vs. @Mock

Open mreines opened this issue 11 years ago • 1 comments

In a scenario where one might use Spring to Inject a Collection of all implementations of a certain Interface, I've found that I can use @Mock to inject multiple instances, but @Spy didn't work (Collection<MyInerface> was null).

Is this supported by Mockito Collections or am I doing something wrong? If not supported I would be interested in adding this to this project.

mreines avatar Sep 23 '13 14:09 mreines

Sounds sensible, this isn't something that's currently supported. If you would like to add this yourself, feel free to submit a pull request. I think this should be a relatively trivial change, the harder part will be providing tests for the various scenarios. I'm not too happy with the current integration test module, but ideally there should be something within the integration tests to cover this.

jameskennard avatar Sep 23 '13 16:09 jameskennard