Thursday, February 28, 2013

Testing Java Applications with Arquilian

For quite some time i want to try Arquilian test framework. 

Arquilian is a Commutity JBoss Open Source project that intend to make it easy to create a Java web application where tests can be naturally created during all the programming life cycle.

One of the things that makes programmers avoid testing nowadays is the fact that java web applications are writen using several resources offered by the application containers like Data Sources for persistence, Context and Dependence Inversion, Transaction mechanisms and so on.

Now you can avoid the use of mocks and test your applications with the real resources implementations offered by application servers in a easy way.

I tested and worked like a charm.

I started reading and implementing the steps of this guide to create the project structure with the necessary dependencies. This could be done with JBoss Forge, but i choose Maven and it was very simple. By the end of this guide, i could get my first green-bar testing a simple CDI Bean.

On the second guide, i could see Arquilian using a remote JBoss AS 7 to run and debug my tests.

And finally, on the third guide  i followed the steps to test an application using JPA to store and retrieve some data from database.