• page

Maven funcunit.maven

 

Maven is a build tool, usually used for Java projects. FuncUnit can be run from maven as part of the build, using the maven antrun plugin.

 <plugin>
   <artifactId>maven-antrun-plugin</artifactId>
   <version>1.6</version>
   <executions>
     <execution>
       <id>funcunit</id>
       <phase>test</phase>
       <configuration>
         <tasks>
            <echo>Running funcunit tests</echo>
            <exec dir="src/main/webapp/ui" executable="src/main/webapp/ui/js"
                  resolveexecutable="true">
              <arg value="-e" />
              <arg value="funcunit/run" />
              <arg value="phantomjs" />
              <arg value="funcunit.html" />
            </exec>
         </tasks>
       </configuration>
       <goals>
         <goal>run</goal>
       </goals>
     </execution>
   </executions>
 </plugin>

Failing on errors

To force maven to fail the build on errors, FuncUnit has to exit "hard" with exit code 1 if there's a failure. Run the js script with the "-e" flag as shown above. This tells the batch script to exit hard if something throws an error. If this property is set, xunit will exit with exit code 1 if there are failed tests.