This is working really good now in my AppFuse 2.0.2 project. It runs all the tests, generates a nice html report, and the junit report for Hudson, and then checks if all tests were successful. Below is the relevant fragment of my pom. The webtest-maven-plugin version I'm using is the one generated from the svn repo, revision 12843. http://svn.codehaus.org/mojo/trunk/sandbox/webtest-maven-plugin
<plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>0.3</version> <configuration> <wait>${cargo.wait}</wait> <container> <containerId>${cargo.container}</containerId> <type>${cargo.type}</type> <zipUrlInstaller> <url>${cargo.container.url}</url> <installDir>${installDir}</installDir> </zipUrlInstaller> </container> <configuration> <home>${project.build.directory}/${cargo.container}/container</home> <properties> <cargo.hostname>${cargo.host}</cargo.hostname> <cargo.servlet.port>${cargo.port}</cargo.servlet.port> <cargo.context>${project.build.finalName}</cargo.context> </properties> </configuration> </configuration> <executions> <execution> <id>start-container</id> <phase>pre-integration-test</phase> <goals> <goal>start</goal> </goals> </execution> <execution> <id>stop-container</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>webtest-maven-plugin</artifactId> <version>0.6.7-isigma</version> <executions> <execution> <id>webtest-test</id> <phase>integration-test</phase> <goals> <goal>test</goal> </goals> <configuration> <host>${cargo.host}</host> <port>${cargo.port}</port> <sourcedirectory>src/test/resources</sourcedirectory> <sourcefile>web-tests.xml</sourcefile> <target>${webtest.target}</target> <basepath>${project.build.finalName}</basepath> <resultpath>target/webtest/webtest-results</resultpath> <haltonfailure>false</haltonfailure> <haltonerror>false</haltonerror> <failureproperty>testError</failureproperty> <loglevel>error</loglevel> </configuration> </execution> <execution> <id>webtest-report-html</id> <phase>post-integration-test</phase> <goals> <goal>report</goal> </goals> </execution> <execution> <id>webtest-report-junit</id> <phase>post-integration-test</phase> <goals> <goal>report</goal> </goals> <configuration> <reportoverviewxsl>WebTestOverview2JUnit.xsl</reportoverviewxsl> <reportname>WebTestOverview.junit.xml</reportname> </configuration> </execution> <execution> <id>webtest-verify</id> <phase>verify</phase> <goals> <goal>verify-result</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>com.canoo.webtest</groupId> <artifactId>webtest</artifactId> <version>3.0</version> <!-- groovy-all doesn't have a pom in central repo --> <!-- exclude groovy to prevent trying to fetch pom --> <exclusions> <exclusion> <groupId>groovy</groupId> <artifactId>groovy-all</artifactId> </exclusion> <exclusion> <groupId>net.sourceforge.htmlunit</groupId> <artifactId>htmlunit</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>net.sourceforge.htmlunit</groupId> <artifactId>htmlunit</artifactId> <version>2.5</version> </dependency> </dependencies> </plugin> 2010/11/3 Matt Raible <m...@raibledesigns.com> > Thanks Josep! If there's a new release of the webtest-maven-plugin before > AppFuse's next release (this month), I'll make sure and switch to the > plugin. > > > On Fri, Oct 29, 2010 at 11:07 AM, Josep García <jgar...@isigma.es> wrote: > >> Hello, >> I have succeded in the integration of webtest-maven-plugin into AppFuse >> 2.0.2. >> Below is the diff. >> Beware, where it says 0.6.7-isigma, it means the trunk version of >> webtest-maven-plugin from the cvs repo: >> http://svn.codehaus.org/mojo/trunk/sandbox/webtest-maven-plugin >> >> It seems the webtest-maven-plugin-0.6.7-SNAPSHOT.jar artifact available in >> the maven repo is different from the one generated from a fresh checkout! I >> renamed the version in my local installation to 0.6.7-isigma so there is no >> mix-up. >> >> If you don't use the fresh one, you will get an error: >> >> Embedded error: import requires support in ProjectHelper >> [INFO] >> ------------------------------------------------------------------------ >> [INFO] Trace >> org.apache.maven.lifecycle.LifecycleExecutionException: >> ... >> >> With these, you can do a "mvn clean verify site" and you'll get a nice >> Webtest report :-) >> Beware, I have configured it so it does not fail if any webtest fails. >> >> Cheers, >> Josep >> >> Diff: >> diff -r 82ed445c829b pom.xml >> --- a/pom.xml Fri Oct 29 18:36:06 2010 +0200 >> +++ b/pom.xml Fri Oct 29 18:52:38 2010 +0200 >> @@ -686,31 +686,19 @@ >> <reporting> >> <plugins> >> <plugin> >> - <artifactId>maven-changes-plugin</artifactId> >> - </plugin> >> - <plugin> >> - <artifactId>maven-checkstyle-plugin</artifactId> >> + <artifactId>maven-surefire-report-plugin</artifactId> >> + <reportSets> >> + <reportSet> >> + <reports> >> + <report>report-only</report> >> + </reports> >> + </reportSet> >> + </reportSets> >> </plugin> >> <plugin> >> <groupId>org.codehaus.mojo</groupId> >> - <artifactId>cobertura-maven-plugin</artifactId> >> - <version>2.0</version> >> - </plugin> >> - <plugin> >> - <artifactId>maven-javadoc-plugin</artifactId> >> - </plugin> >> - <plugin> >> - <artifactId>maven-jxr-plugin</artifactId> >> - </plugin> >> - <plugin> >> - <artifactId>maven-pmd-plugin</artifactId> >> - <configuration> >> - <linkXref>true</linkXref> >> - <targetJdk>1.5</targetJdk> >> - </configuration> >> - </plugin> >> - <plugin> >> - <artifactId>maven-surefire-report-plugin</artifactId> >> + <artifactId>webtest-maven-plugin</artifactId> >> + <version>0.6.7-isigma</version> >> </plugin> >> </plugins> >> </reporting> >> @@ -733,7 +721,7 @@ >> <wait>${cargo.wait}</wait> >> <container> >> >> <containerId>${cargo.container}</containerId> >> - <!--home>${cargo.container.home}</home--> >> + <type>${cargo.type}</type> >> <zipUrlInstaller> >> <url>${cargo.container.url}</url> >> >> <installDir>${installDir}</installDir> >> @@ -765,50 +753,37 @@ >> </executions> >> </plugin> >> <plugin> >> - <artifactId>maven-antrun-plugin</artifactId> >> - <version>1.1</version> >> - <configuration> >> - <tasks> >> - <taskdef >> resource="webtest_base_relaxed.taskdef"> >> - <classpath >> refid="maven.test.classpath"/> >> - </taskdef> >> - <mkdir dir="target/webtest-data"/> >> - <!-- Delete old results file if it exists >> --> >> - <delete >> file="target/webtest-data/web-tests-result.xml"/> >> - <!-- This is so the default will be used >> if no test case is specified --> >> - <property name="test" >> value="run-all-tests"/> >> - <echo level="info">Testing >> '${project.build.finalName}' with locale '${user.language}'</echo> >> - <ant >> antfile="src/test/resources/web-tests.xml" target="${test}"> >> - <property name="user.language" >> value="${user.language}"/> >> - <property name="webapp.name" >> value="${project.build.finalName}"/> >> - <property name="host" >> value="${cargo.host}"/> >> - <property name="port" >> value="${cargo.port}"/> >> - </ant> >> - </tasks> >> - </configuration> >> + <groupId>org.codehaus.mojo</groupId> >> + <artifactId>webtest-maven-plugin</artifactId> >> + <version>0.6.7-isigma</version> >> <executions> >> <execution> >> + <id>webtest-test</id> >> <phase>integration-test</phase> >> <goals> >> - <goal>run</goal> >> + <goal>test</goal> >> + </goals> >> + <configuration> >> + <host>${cargo.host}</host> >> + <port>${cargo.port}</port> >> + >> <sourcedirectory>src/test/resources</sourcedirectory> >> + >> <sourcefile>web-tests.xml</sourcefile> >> + <target>run-all-tests</target> >> + >> <basepath>${project.build.finalName}</basepath> >> + >> <resultpath>target/webtest/webtest-results</resultpath> >> + <haltonfailure>false</haltonfailure> >> + <haltonerror>false</haltonerror> >> + <loglevel>error</loglevel> >> + </configuration> >> + </execution> >> + <execution> >> + <id>webtest-report</id> >> + <phase>post-integration-test</phase> >> + <goals> >> + <goal>report</goal> >> </goals> >> </execution> >> </executions> >> - <dependencies> >> - <dependency> >> - <groupId>com.canoo.webtest</groupId> >> - <artifactId>webtest</artifactId> >> - <version>${webtest.version}</version> >> - <!-- groovy-all doesn't have a pom in >> central repo --> >> - <!-- exclude groovy to prevent trying to >> fetch pom --> >> - <exclusions> >> - <exclusion> >> - <groupId>groovy</groupId> >> - >> <artifactId>groovy-all</artifactId> >> - </exclusion> >> - </exclusions> >> - </dependency> >> - </dependencies> >> </plugin> >> </plugins> >> </build> >> diff -r 82ed445c829b src/test/resources/config.xml >> --- a/src/test/resources/config.xml Fri Oct 29 18:36:06 2010 +0200 >> +++ b/src/test/resources/config.xml Fri Oct 29 18:52:38 2010 +0200 >> @@ -1,5 +1,16 @@ >> -<config host="${host}" port="${port}" protocol="http" >> - basepath="${webapp.name}" resultpath="target/webtest-data" >> saveresponse="true" >> - resultfile="web-tests-result.xml" summary="true"> >> +<config >> + host="${host}" >> + port="${port}" >> + protocol="http" >> + basepath="${basepath}" >> + saveresponse="true" >> + haltonfailure="${haltonfailure}" >> + haltonerror="${haltonerror}" >> + resultpath="${resultpath}" >> + resultfile="web-tests-result.xml" >> + summary="true"> >> <header name="Accept-Language" value="${user.language}"/> >> -</config> >> \ No newline at end of file >> + <option name="ThrowExceptionOnScriptError" value="false"/> >> + <option name="ThrowExceptionOnFailingStatusCode" value="false"/> >> + >> +</config> >> diff -r 82ed445c829b src/test/resources/web-tests.xml >> --- a/src/test/resources/web-tests.xml Fri Oct 29 18:36:06 2010 +0200 >> +++ b/src/test/resources/web-tests.xml Fri Oct 29 18:52:38 2010 +0200 >> @@ -3,9 +3,10 @@ >> <!ENTITY login SYSTEM "./login.xml"> >> ]> >> <project basedir="." default="run-all-tests"> >> + <taskdef resource="webtestTaskdefs.properties" /> >> <!-- Use i18n bundle, 2nd one listed is the default --> >> - <property file="\${basedir}/target/${webapp.name >> }/WEB-INF/classes/ApplicationResources_${user.language}.properties"/> >> - <property file="\${basedir}/target/${webapp.name >> }/WEB-INF/classes/ApplicationResources.properties"/> >> + <property >> file="../../../target/classes/ApplicationResources_${user.language}.properties"/> >> + <property >> file="../../../target/classes/ApplicationResources.properties"/> >> >> <!-- runs all targets --> >> <target name="run-all-tests" >> @@ -215,7 +216,7 @@ >> <invoke description="click Upload a File link" >> url="/uploadFile.html"/> >> <verifytitle description="we should see file upload form" >> text=".*${upload.title}.*" regex="true"/> >> <setinputfield description="set name" name="name" >> value="Canoo Test File"/> >> - <setFileField description="set file" name="file" >> fileName="pom.xml"/> >> + <setFileField description="set file" name="file" >> fileName="../../../pom.xml"/> >> <clickbutton label="${button.upload}" description="Click >> Upload"/> >> <verifytitle description="show file data if upload OK" >> text=".*${display.title}.*" regex="true"/> >> <verifytext description="verify original filename >> displayed on page" text="pom.xml"/> >> >> [image: isotipo isigma] >> Josep García Corral >> Ingeniero de Software >> isigma, la referencia en firma electrónica >> Tel. +34 932 387 108 >> www.isigma.es >> >> [image: logotipo portasigma] >> ¡Prueba gratis la firma online! <http://www.portasigma.com> >> > >