Previous Section
Table of Contents
Next Section

Chapter 20: Testing Struts Applications

Testing, and unit testing in particular, has become a hot topic in software development in recent years. Spurred on by the advent of agile methodologies such as Extreme Programming and Scrum, developers are placing a greater emphasis on software testing. Successful iterative development hinges on having repeatable tests that can be run with every build. Because of this need, this chapter covers testing Struts applications. Before you read about how to test a Struts application, however, take a look at the types of testing that are applicable.

Types of Testing

There are different levels, or types, of testing. Each type serves different purposes. Traditionally, testing is viewed as a quality control function. However, unit testing is considered to be in the development domain. This chapter covers testing from both of these perspectives. However, the primary focus will be on the types of tests run by developers.

Unit Testing

Unit testing refers to independent testing of individual software units. In Java development, a unit is typically associated with a Java class. Unit testing is normally performed by the developer, not the quality assurance or quality control department. The goal of unit testing is to ensure that the unit under test does what it is supposed to do. More specifically, the developer specifies in a unit test what the expected output or behavior of individual methods is for a given set of inputs. Unit testing is typically associated with the xUnit family of software testing frameworks led by the JUnit framework.

The folks at the Cactus project (, a testing framework covered in the “Using Cactus for Integration Unit Testing” section, refer to the following three specific types of unit testing:

  • Code logic testing  The traditional view of unit testing, where the unit is completely isolated.

  • Integration unit testing  Testing of a unit that is not in isolation; that is, the unit communicates with other units.

  • Functional unit testing  An integrated unit test that verifies the output of a unit for a known input. The unit in this case is typically not a software unit per say, but an application unit (for example, a Web page). Functional unit testing can be considered black-box integration testing.

This chapter covers several tools and techniques that assist with unit testing.

Functional Testing

Functional testing is driven by requirements and use cases and is usually performed by a quality control group. Functional tests ensure that the application performs the functions specified by the requirements. Functional tests are typically focused on verifying that the application or components of the application respond with the expected output when given known input. For Web applications, functional tests can be automated using testing tools.

System Testing

Performance is an important aspect of most applications. System testing is concerned with measuring and verifying the response of the system when the application is run under varying loads. System responses include such things as performance/latency, throughput, and memory consumption. At the end of this chapter, two open-source tools are presented that can measure and analyze this type of data.

Previous Section
Table of Contents
Next Section