Using the Maven Cactus Plug-in Vincent Massol
  1. Create a src/test-cactus directory in your project and put your Cactus test classes in it (with the normal package directory structure). Note that the location of the Cactus test sources can be configured through the maven.cactus.src.dir property.
  2. Create a build.properties file in your project root directory (where project.xml is located) and define in it the location of the container you wish to use for the tests. For example, if you wish to run the Cactus tests on Tomcat 4.1.10 and on Resin 2.4, you will write:
  3. Call the War plugin's goals to generate a war for your webapp. For example: maven war. Note that in the future you would also be able to call the Ear plugin if your application is an EAR.
  4. Then, simply run the Cactus goal for your container. For example, type maven cactus:test-tomcat-4x to run the tests with Tomcat 4.x. You can type maven -g for a full list of the available goals.
  5. If you wish to generate Cactus HTML test reports, type maven cactus:generate site.

The plugin will automatically add what is needed for the Cactus tests to your application WAR/webapp by repackaging it. In detail, it will add the Cactus test classes, Cactus configuration files and Cactus jars to your WAR/webapp. It will then deploy it, configure the container you have chosen, start it, run the Cactus tests and stop the container.

It is possible (and recommended for performance reasons) to run all the goals in one Maven invocation. For example: maven war cactus:test-tomcat-4x cactus:generate site. You can also put that sequence in your project's maven.xml file.