Testing Struts Apps With Maven

While switching my configuration manager project from Maven 1 to Maven 2, I had to figure out how to add WEB-INF/web.xml located in src/main/webapp directory to the Maven test class path, so that MockStrutsTestCase would be able to access it. After a bit of digging on the net, and experimenting, I found an easy way of accomplishing it. Here is what needs to be added to your POM:
<plugins>
<
plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/src/main/webapp</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugin>

After I’ve added this fragment, all the tests I’ve ported passed! Hurray!


Leave a Reply

You must be logged in to post a comment.