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

EasyMock CDI extension #1

Closed
wants to merge 40 commits into from

Conversation

marciopd
Copy link

@marciopd marciopd commented Aug 9, 2013

Unit testing CDI (JSR 299) beans using EasyMock is tricky, as the following post suggests: http://stackoverflow.com/questions/16761905/unit-test-with-cdi-unit-and-easymock/16814237#16814237.

As CDI is becoming widely used in new JEE projects, it's important to provide first class support to developers willing to unit test CDI beans using EasyMock.

This pull request is about a portable CDI extension, which provides a clean way of unit testing CDI beans and mocking its collaborators using EasyMock.

JIRA request:
https://jira.codehaus.org/browse/EASYMOCK-126

More details in README.md:
https://github.com/marciopd/easymock/tree/master/easymock-cdiextension

I think this could be a great new feature to EasyMock and I'm open to suggestions or doing any other efforts needed in order to make it happen. In fact, I'm already needing badly a extension like this in my company's projects.

cheers

- Adding validation to mock definitions.
- Testing multiple TestSubject in the interceptor example.
- Removing Demoiselle junit dependency.
- Created profiles to test the extension with different weld versions.
@henri-tremblay
Copy link
Contributor

Is this still relevant?

From what I read on stack overflow, CDI-unit or needle seem to solve the issue.

Also, the root of your problem seems to be that EasyMock cannot recognize a mock if it is subclassed. Indeed, that wasn't expected. But could be fixed.

@marciopd
Copy link
Author

I did some tests with CDI-unit and needle and it worked better this time.
CDI-unit is dealing better with mocks and it's easier to produce them without conflicts.
The subclassed problem didn't happen.

Maybe the only thing this contribution adds is allowing to mock a interceptor's collaborators during interception (https://github.com/marciopd/easymock/blob/master/easymock-cdiextension/src/test/java/org/easymock/cdi/interceptor/InterceptorTest.java).

Should we close the issue?

@henri-tremblay
Copy link
Contributor

Sorry. This has been pending for a long long time now. I really do not want to add that much code just to support CDI. I don't think EasyMock should be that involved in "in container mocking". I do appreciate your effort and I am side I can't merge this.

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

Successfully merging this pull request may close these issues.

None yet

2 participants