Setting Up a Stable Build Environment
Problem
You want to configure your environment to support test-first development with Cactus, Tomcat, and Ant.
Solution
Create an Ant buildfile to automatically build, start Tomcat, deploy to the server, execute your web application’s test suite, and stop Tomcat.
Discussion
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,
typing 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access