Section 18.1. What s Covered Here?


18.1. What's Covered Here?

This chapter demonstrates unit testing using both JUnit 3.8.1 and Cactus 1.7, the latest releases of both of these tools at the time of this writing.

JUnit is a generic Java unit testing framework that can be used in any Java environment. You can download this tool from http://www.junit.org. We've written and executed the unit tests demonstrated in this chapter using a JDK 1.4.2 environment.

Cactus is a JUnit extension that allows you to write tests that execute inside a J2EE container. The Cactus framework supports unit testing of various J2EE components, like servlets and EJBs, and other server-side J2EE code, like JSP tags and servlet filters, that depend on a server-side container environment in order to function. You can download Cactus from http://jakarta.apache.org/cactus. The Cactus test examples in this chapter were run in JBoss 4.0 and WebLogic 9.0 server environments.

18.1.1. Other Tools to Consider

We chose to cover JUnit and Cactus in this tutorial because, as with the other tools we've chosen, these unit testing tools are in wide use and are a good place to start for your testing needs. Of course, other tools that you can use to supplement or replace the functionality provided by JUnit and Cactus are available. Some of these include:


MockObjects (http://www.mockobjects.com)

This site provides a set of frameworks for testing code using the mock objects approach, which is an alternative approach to the in-container testing supported by Cactus. Some of these mock objects frameworks can be used alone, with JUnit, and with Cactus.


StrutsTestCase (http://strutstestcase.sourceforge.net)

This JUnit extension supports the testing of Struts actions, mappings, and beans. It can be used with JUnit, with or without Cactus.



Java Enterprise in a Nutshell
Java Enterprise in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596101422
EAN: 2147483647
Year: 2004
Pages: 269

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net