Mockrunner is a lightweight framework for unit testing applications in the J2EE environment. It supports servlets, filters, tag classes and Struts actions and forms. Furthermore it includes a JDBC, a JMS and a JCA test framework and can be used in conjunction with MockEJB to test EJB based applications.

Mockrunner extends JUnit and simulates the necessary behaviour without calling the real infrastructure. It does not need a running application server or a database. Furthermore it does not call the webcontainer or the Struts ActionServlet. It is very fast and enables the user to manipulate all involved classes and mock objects in all steps of the test. It can be used to write very sophisticated unit-tests for J2EE based applications without any overhead. Mockrunner does not support any type of in-container testing.

Mockrunner does not read any configuration file like web.xml or struts-config.xml. You can specify all parameters using the Mockrunner API. So it is possible to test servlets, filters, tags and Struts actions as reusable components regardless of the settings you use in one or another application. It is not possible to test the definitions in the configuration files. If you want to do that you can use StrutsTestCase for Struts based applications or Cactus.

The JDBC test framework simulates a database but it does not execute any SQL statements. You can use the Mockrunner API to specify the results the database would provide when executing different SQL statements. The framework is meant for testing the Java part of JDBC based applications. If you want to test SQL code you can use SQLUnit or dbUnit which runs against a real database. The JDBC test framework can be combined with any other Mockrunner test module.

The JMS test framework implements all JMS interfaces and can be used to test JMS based code. The JMS test framework is able to send and receive messages and to keep track of everything that happens while delivering the message. Receivers can be plain Java classes or message driven beans.

The JCA test framework can be used to simulate backend systems that are accessed through the use of the JCA Common Client Interface API. Application code that uses the Common Client Interface can be executed against a simulated connector. The test framework intercepts the backend call and provides a suitable response.

To start with Mockrunner check out the JavaDoc of each module and the examples on this page and in the release. Mockrunner is hosted on Github.

Copyright © 2013 Mockrunner project and Alwin Ibba