Enterprise JUnit Beans 3

What is it?

Enterprise JUnit Beans 3 is a unit test framework that allows regular JUnit tests to test Entities and Session Beans.

Project's site on sf.net is here.

The currently state of EJB3 test frameworks

Here is a brief:

Enterprise JUnit Beans 3 framework

The JUnit tests will work much alike regular Session Beans. They are empowered with dependency injection by using the EJB3 annotations such as @EJB, @PersistenceUnit and @PersistenceContext. Also, all test methods run on a transaction context. This all happens while your beans are tested inside a real EJB3 Container. Of course, there is no need for your tests to implement any EJB interface as they are not real session beans and don't run inside the container. Only your entities and session beans will be deployed. But, yet, your JUnit tests will seem like EJB3s. Or should we say Enterprise JUnit Beans 3! ;-)

Because of this, the tests can be run by any JUnit test runner like the one embedded on your preferred IDE.

Considerations on the EJUnitB3 framework

The beans are deployed on a standalone EJB3 container. The project works with Jboss EJB3 Container Embedded but future releases may use other standalone containers such as EasyBeans, OpenEJB and the GlassFish EJB Container (once it has standalone capabilites - please check [Issue 1864] Embeddable EJB container and vote).

It is easy to adapt it to use another standalone EJB3 Container. The only effort is to write a class that implements the EJB3Container interface or that extends the AbstractEJB3Container and write it's name on a properties file.

The tests run as JUnit 4 tests, JUnit 3.8.x and TestNG.

The support for dependency injection annotations ON TESTS is currently limited to @EJB, @PersistenceUnit and @PersistenceContext. It will probably cover most of the tests needs for now. The dependency injection support on Session Beans is complete as it depends only on the container.

The EJUnitB3 imposes no restrictions like extending classes. It uses AspectJ to inject the dependencies. The default supported configuration is by load time weaving so it doesn't require you to compile your test classes with a different compiler but there is no restriction if you want to compile it with ajc. In fact it makes loading time shorter.

There is no release yet, the only way to have the framework running immediately is by checking it out from the SVN repository at https://ejunitb3.svn.sourceforge.net/svnroot/ejunitb3. There will be a first release VERY soon.

As there is no release yet, no documentation is provided also. There is an example of how to make it work on our SVN repository.

And we need a better site. A logo would be welcome too. ;-)

At last, but not least, contributors are more than welcome.

SourceForge.net Logo