Started JEE – Testing with Arquillian

Some time ago I came to the point where I need to do integration tests for my JEE applications at work. In Spring this is fairly easy, just use the SpringJUnitRunner and most of the work is done by Spring. Possibly you have to choose the right profile or do some minor configuration setup. But it’s really easy.

In JEE6 I tried several testing frameworks two years ago, but none of them works very well, so we decided to skip this point and continue with end users tests and JUnit testing. One exception we made for our controller classes that instruments the database and did some complex calculations on the data. From this approach my JUnit rules framework starts from.

But I never gave up the search for an testing framework for JEE6.  Before I (re-)stumbled upon Arquillian, I found which is a nice JUnitRunner for testing CDI applications. But it misses EJB and the container stuff.

A few weeks ago I came (again) across Arquillian and was again amazed about their promise and idea “Do real integration testing within the real runtime environment”.

The first steps were hard, especially figuring out how the ShrinkWrap works correct, but after these initial hirdles I became more and more familiar with Arquillian and I won’t miss it anymore in my toolbox.

My personal best of of the features of Arquillian are

  • it’s fast. If you don’t have a very complex structure or setup, testing with Arquillian feels like Unit Testing
  • 100% IDE support (except of my special build setup ;) )
  • coverage can be calculated via JaCoCo (a promising new kid on the block)
  • you don’t have to start your whole application. Just add the parts you need for this class of tests.
  • deployment of the tests is done in the “real” environment, not in an “like the real” environment.

But where light is is also shadow:

  • you must know the dependencies of your system under test. If one is missing the testclass will fail. But this is good, because after this you are very familiar with the dependencies.
  • when using a remote server, usually you must have a SSL-Connection and for this a java acceptable certificate or the certificate has to installed in the trust-store of java where the test runs.
  • gradle dependency resolution support is not available. But I found some ideas on github.

During this week I will prepare some examples and provide them to you.


Leave a Reply