You want to configure your environment to support test-first development with Cactus, Tomcat, and Ant.
Create an Ant buildfile to automatically build, start Tomcat, deploy to the server, execute your web application’s test suite, and stop Tomcat.
Setting up an Ant buildfile to properly handle Cactus tests is
nontrivial and deserves some explanation A successful environment
allows developers to make and test small code changes quickly, and
requires a server that supports hot deploying. The ability to hot
deploy a modified web application is critical for test-first
development because it takes too long to restart most servers. Tomcat
provides a built-in web application called
manager that supports hot deploying. For more
information on Tomcat see Chapter 10.
Figure 7-2 shows a graphical view of the Ant
buildfile we are creating. Setting up a stable and easy-to-use
environment is imperative for server-side testing. For example,
ant cactus prepares the development environment, compiles all out-of-date files, creates a new WAR file, starts Tomcat (if it isn’t already started), removes the old web application (if it exists), deploys the updated web application, and invokes the Cactus test suite. The developer does not have to worry about whether the server is started. Ant takes care of the details, allowing developers to concentrate on writing testable code. If the tests are too hard to execute, then developers will ...