-
Notifications
You must be signed in to change notification settings - Fork 67
Provide a CDI-Embedded Container to faciliate testing #35
Description
It would be quite easy to test JEE Applications using a CDI container that runs outside the Application Server. Weld already provides a CDI Container for Java SE (Weld-SE). I have been using this approach to test JEE Applications in several customer projects and the feedback has been good.
Please see this post for detailed information about this approach:
http://blog.novatec-gmbh.de/unit-testing-jee-applications-cdi/
The source code can be found on:
https://github.com/NovaTecConsulting/BeanTest
The example described in the post uses standard CDI features to make it possible to test JEE applications with (almost) all its dependencies resolved by the CDI Container. It runs like a normal Unit test, which means that the tests need milliseconds to run. It uses local transactions which it is ok for testing purposes. It also uses CDI extensions to "convert" EJBs into normal CDI Beans, so it aligns very well in the direction where JEE8 is going, namely, CDI instead of EJBs.
I think this feature will help a lot with testing. Besides, the approach uses other well established specs like JPA. I think that the technical aspects for this feature are already solved. The specs and infrastructure needed are already out there.
I know there is an Embedded Container already but it is very hard (almost impossible) to properly configure it in large projects.
Arquillian is a very good framework but I think it is used more for integration tests (deployment is still required in most cases).