Java Reference
In-Depth Information
important. This way we first prepare the cactified archive for deployment, and then
we start the container with this archive as a deployable. We also attach this plug-in's
stop goal with the post-integration-test phase
I
. This is normal; we need to stop the
container once the tests are executed.
Listing 14.20 displays the third plug-in: the
maven-surefire-plugin
.
Listing 14.20
Continuation of the plug-in declarations from listing 14.19
<!—We continue from listing 14.19-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<systemProperties>
<property>
<name>cactus.contextURL</name>
</property>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
The last plug-in declaration is for the
maven-surefire-plugin
J
. As you already saw
in chapter 10, this Maven plug-in is responsible for executing
JU
nit tests. Because
every Cactus test is also a
JU
nit test, we can use this plug-in to execute our Cactus tests.
There are a couple of things to notice in its declaration. As you can see, we declare the
skip
parameter with
true
. That's because the Surefire plug-in is by default
attached to the test phase. We surely don't want it attached to this phase, so we declare
the
skip
parameter to
true
, which will cause the plug-in to skip the execution. Fur-
ther in the declaration we attach the test goal with the integration-test phase
(where we want it to be), and we declare the
skip
parameter with
false
. This will
cause the plug-in to execute the tests in the integration-test phase, just as we want it to
happen. There's also one thing to remember: whenever you execute Cactus tests, you
always have to specify
cactus.contextURL
. The Cactus Ant task does it for you, but
the Surefire plug-in doesn't, so that's what we do in the last part.
J
1)
1!
1@
1#
1)
1!
1@
1#