StrutsTestCase Testing Framewok (Part 1): Introduction

December 2016

Introduction to the StrutsTestCase Test Framewok


The StrutsTestCase testing framework of Java JEE applications is an extension of the standard JUnit testing framework. The legacy of the TestCase class allows the testing of codes based on the Struts framework. StrutsTestCase is based on two different approaches to test the Struts code:
  • by running the ActionServlet is in a real environment with a standard servlet
  • by running it in a standard simulation environment.

We refer to these two approaches as:
  • The in-container approach.
  • The Mock Object approach

StrutsTestCase make use of the ActionServlet controller to test code, thus offering numerous testing possibilities:
  • Implementation of "Action".
  • FormBeans
  • Forward statements and associated path
  • Error messages returned by the actions. '

Moreover, StrutsTestCase already provided validation methods (assertEquals, assertNotNull, ...) to make unit testing more thorough, quick and easy.
StrutsTestCase is hosted on SourceForge on this link.

The different approaches

As mentioned above, most common approaches to test the server-side classes are:
  • Mock objects: class test this approach by simulating the server container.
  • In-container: testing the classes,by running them in real servlet container.

StrutsTestCase allows you to switch from one approach to another, with a minimal impact on test classes. In fact, the configuration and validation methods are exactly the same for both approaches.
StrutsTestCase provided two base classes:
  • MockStrutsTestCase: It uses HttpServlet to simulate the container.
  • CactusStrutsTestCase: It uses the cactus test framework to test the Struts classes in a container of real server

List of jars of StrutsTestCase

The StrutsTestCase framework is made up of the following libraries:

  • strutstest-2.1.3.jar
  • junit-3.8.1.jar
  • ant-junit.jar

  • cactus-ant-1.7.2.jar
  • httpunit-1.6.jar
  • nekohtml-0.9.1.jar
  • commons-logging-1.0.4.jar"
  • commons-httpclient-2.0.2.jar

Related :

This document entitled « StrutsTestCase Testing Framewok (Part 1): Introduction » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.