I do system tests of our Java EE applications deployed on remote JBoss instance.
I’m testing whether the system provides the right data after settings the system in a certain state.
- System’s state is updated by populating DB via JDBC, calling RMI APIs and sending messages to the external queue (openMQ), all that from a single JUnit test case
- System’s state is read by calling RMI APIs from JUnit tests
- System’s is set to initial state by a set of shell and SQL scripts (reseting DB schema, purgueing queue, restarting JBoss and resetting its state)
Even if the whole process is automated, I’m not very satisfied of how this is done now, because
- It takes a minute or two to set the system in an expected state. The significant time of this process is taken by restarting JBoss (Hibernate cache is purged by removing tmp, work, cache, data catalogs), removing all tables, sequences and other DB objects and importing DB dump.
- I mix different technologies (bash, imp, Java) to reset system under test and scripts are located on different machines. For instance, I still need to call automated scripts on a remote machines manually to reset DB, queue and JBoss. This not only complicate reset process but also makes maitenance of the whole test harder.
I would like to make this solution faster and clearer. Yes, I could study the technologies more, but I wonder is there any best practice or example from which I could learn?
One thing you could look at here is Arquillian. If you keep each test case small and use a modern JBoss AS version (7.1), then restarting JBoss takes a second, maybe two at most.
DBUnit can help with setting up your database. If you keep each test case small, the amount of tables that need to be purged and set to a known state should be relatively small and typically be done in mere seconds.