JsUnit
Project Developer Home doxygen

Apache Maven 2

Maven 2 is a build tool from the Apache Software Foundation generally used for Java development. It uses a Project Object Model defined in a pom.xml file to describe the build. Maven 2 uses a lifecycle where at each phase of this lifecycle different goals can be attached that are provided by plugins. The JsUnit plugin is automatically attached to the test test phase.

The JsUnit plugin uses Rhino to perform the JavaScript tests.

The Maven 2 Repository at BerliOS

The artifacts of JsUnit and its plugin is located in the Maven 2 repository at BerliOS. The released versions will also be available at Maven's central repository, but the upload procedure may cause some time gap. The reports generated by Maven are also available.

Using the Maven 2 Plugin

The JsUnit Maven plugin has simply to be declared in the build section with the other plugins. As usual with Maven 2 all necessary dependencies are automatically available. The plugin itself is published with groupId de.berlios.jsunit and artifactDi jsunit-maven2-plugin in the Maven repository of JsUnit at BerliOS and in Maven's central repository also.

The configuration section of the plugin has following elements:

Name Description Default
printSummary A flag to enable a summary for the performed unit tests. ${maven.test.skip}
reportsDirectory The directory where the plugin writes the results of the unit tests. ${project.build.directory}/surefire-reports
skip A flag to skip the JavaScript unit tests completely. ${maven.test.skip}
skipExec A flag to skip the execution of the JavaScript unit tests, but the JavaScript code is still loaded into the JavaScript engine to detect possible syntax problems. ${maven.test.skip.exec}
sourceDirectory The root directory for the JavaScript sources. All source declarations are relative to this setting. ${basedir}/src/main/webapp/js
sources An array of source elements. Each element contains a name to a JavaScript source file (relative to the path given in sourceDirectory). The sequence of the source elements define the sequence the files are loaded into the JavaScript engine. ${basedir}/src/main/webapp/js
testFailureIgnore A flag to allow the current build to continue ignoring possible test failures. ${maven.test.failure.ignore}
testSourceDirectory The root directory for the JavaScript unit test sources. All include declarations in a testSuite are relative to this setting. ${basedir}/src/test/js
testSuites An array of testSuite elements.  

A testSuite contains following elements:

Name Description Default
includes An array of include elements. Each element defines a file pattern with a name relative to the testSourceDirectory element.  
name The name of the test suite.  
type The type of the test suite, one of the following values:
ALLTESTS
Looks for a class AllTests derived from TestSuite and runs its suite.
TESTSUITES
Looks for all classes ending with TestSuite and that are derived from TestSuite and run their suites.
TESTCASES
Looks for all classes ending with TestCase and that are derived from TestCase and runs them (the default).
TESTCASES

Example build.xml

The following JsUnit plugin declaration is used in the POM file of the samples directory.

<plugin>
<groupId>de.berlios.jsunit</groupId>
<artifactId>jsunit-maven2-plugin</artifactId>
<executions>
<execution>
<id>test</id>
<configuration>
<sourceDirectory>.</sourceDirectory>
<sources>
<source>money/IMoney.js</source>
<source>money/Money.js</source>
<source>money/MoneyBag.js</source>
</sources>
<testSourceDirectory>.</testSourceDirectory>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<testSuites>
<testSuite>
<name>SampleSuite</name>
<type>TESTCASES</type>
<includes>
<include>money/*.js</include>
</includes>
</testSuite>
</testSuites>
</configuration>
<goals>
<goal>jsunit-test</goal>
</goals>
</execution>
</executions>
</plugin>


JsUnit © 1999, 2000, 2001, 2002, 2003, 2006, 2007 by Jörg Schaible
Generated on Wed Apr 15 2015 02:33:06 for JsUnit by doxygen 1.8.5