I’ve never really had much joy unit testing EJBs. I’ve had a look at Cactus, but never found it that easy to understand (I mean, testing inside the container has to be a good thing for accuracy, but it has to be a pain to regularly deploy test suites to your container on every run?). Inevitably I end up give up after stuffing around for a while.

Anyways, I’ve since discovered MockEJB and it is one very neat little mock library for EJBs. Getting a basic test of my SLSB outside the container was a snap… and not it just runs as part of my standard JUnit test suite (without a stack of dependencies on other infrastructure being up and running).

Another neato feature is a relatively complete Mock JNDI Context. I’m registering little local datasources against the JNDI names the bean is expecting and it works just great.

The other great thing about it is that it comes with some very nice example code of common things you’re likely to want to do, and enough documentation to get you hitting the ground running. Recommended. Great job Alexander!