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

Please support @TestSubject (EasyMock's equivalent to Mockito's @InjectMocks) #605

Closed
volkertb opened this issue Dec 29, 2015 · 1 comment

Comments

@volkertb
Copy link

I spent quite a bit of time studying PowerMock's API documentation, only to come to the conclusion that there currently is simply no way to automatically have PowerMock inject mocks that were annotated with @mock into the class under test. PowerMockito supports @Injectmocks, but that doesn't work when using PowerMock's EasyMock API. As a result, even though we can conveniently create mocks using @mock, we still have to manually inject each mock using Whitebox.setInternalState(). I'm frankly surprised that there is apparently no more convenient way to take care of this.

My feature request is as follows: could you please add the @Testsubject annotation to PowerMock's EasyMock API? @Testsubject is an annotation that tells EasyMockRunner to inject @mock annotated EasyMock mocks into the class under test. It would make perfect sense for PowerMock to support this annotation as well. It would also create feature parity with PowerMockito in this respect.

To be clear, I'm asking for a PowerMock implementation of this EasyMock annotation: http://easymock.org/api/org/easymock/TestSubject.html

I'm aware that a similar request was made in issue #455, but the reason why that request was rejected was due to the desire to remain as close as possible to the EasyMock API. Since @Testsubject is already an existing annotation in EasyMock, that should not be an issue here.

Thank you kindly for considering my request.

Also, feel free to point out an existing way to automatically have PowerMock (not PowerMockito) inject mocks, if there is one. I really couldn't find any.

@johanhaleby
Copy link
Collaborator

I wasn't aware of TestSubject but this is a good suggestion. If you like then please help out will a pull request. You can have a look at how the PowerMockito extension works for InjectMocks and do something similar for the PowerMock EasyMock extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants