Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Test Web applications with HttpUnit

The HttpUnit framework allows the implementation of automated test scripts

  • Print
  • Feedback

In a typical enterprise application, many areas require testing. Starting from the simplest components, classes, the developers or specialized test developers need to program unit tests to ensure that the application's smallest units behave correctly. Each component can potentially pass the unit tests alone; however developers need to ensure they work together as expected—as part of a subsystem, and as part of the whole application—hence, integration tests must be performed. In some projects, performance requirements must be fulfilled, so the quality assurance engineers perform load tests to verify and document how the application performs under various conditions. During application development, quality assurance engineers perform automated and manual functional tests to test the application's behavior from the user's viewpoint. When a development project nearly completes a specific milestone, acceptance tests can be performed to verify that the application fulfilled the requirements.

HttpUnit is a framework based on JUnit, which allows the implementation of automated test scripts for Web applications. It is best suited for the implementation of automated functional tests, or acceptance tests. As the name suggests, it can be used for unit testing; however, typical Web layer components like JSP (JavaServer Pages) pages, servlets, and other template components do not lend themselves to unit testing. As for various MVC (Model-View Controller) framework-based components, these are better suited for testing with other testing frameworks. Struts actions can be unit tested with StrutsUnit, and WebWork 2 actions can be unit tested without a Web container, for example.

Test targets

Before we jump into the architecture and implementation details, it's important to clarify exactly what the test scripts will need to prove about the Web application. It is possible to just simulate the behavior of a casual Website visitor by just clicking on interesting links and reading pages in a random order, but the result of these random scripts would not describe the application's completeness and quality.

A typical enterprise Web application (or a complex Website) has several documents describing the requirements of the various users or application maintainers. These may include use-case specifications, nonfunctional requirements specifications, test-case specifications derived from the other artifacts, user interface design documents, mockups, actor profiles, and various additional artifacts. For a simple application, the whole specification could possibly consist of a simple text file with a list of requirements.

From these documents, we must create an organized list of test cases. Each test case describes a scenario that can be accomplished by a Web visitor through a Web browser. A good practice is to aim for similar-sized scenarios—larger scenarios can be broken down to smaller chunks. Many excellent books and articles discuss the creation of test-case specifications. For this article, let's assume you have a set of items you want to test for your Web application, organized into sets of test-case scenarios.

  • Print
  • Feedback
What is Tech Briefcase?
TechBriefcase is a new, free service where IT Professionals can Search, Store and Share IT white papers and content like this. Learn more
Bookmark content
Speed up your research efforts with content across the web.
Search and Store
Find the white papers you need. Create folders for any topic.
View Anywhere
Open your briefcase on your iPhone, tablet or desktop. Share with colleagues.
Don't have an account yet?

Resources