Automatically exported from code.google.com/p/phantomjs-qunit-runner
This plugin allows you to run QUnit tests in a Maven build. It works by running the QUnit test framework in !PhantomJs (a webkit compliant headless browser) and parses the output to report success or failure. This is especially useful in a continuous integration environment.
See http://kennychua.net/blog/running-qunit-tests-in-a-maven-continuous-integration-build-with-phantomjs for example use
- 7 Oct, 2012: Version 1.0.15 released. Now allows QUnit async tests & better logging of test failures. Credit to Gabor Paller.
- 21 Jul, 2012: Version 1.0.13 released to enable inclusion of user defined librarie when testings. [UsingLibraries See how here]
- 4 Feb, 2011: Version 1.0.11 released to enable DOM tests. [DOMTests See how here] Plugin config params have changed. See below
- 23 Dec, 2011: Version 1.0.6 released to address js file not found bug
- 12 Dec, 2011: Initial release.
Include the following in your pom.xml file. See the Configuration section for more info about the config parameters.
<plugins>
...
<plugin>
<groupId>net.kennychua</groupId>
<artifactId>phantomjs-qunit-runner</artifactId>
<configuration>
<jsSourceDirectory>../src/javascript/location/..</jsSourceDirectory>
<jsTestDirectory>../test/javascript/location/..</jsTestDirectory>
<ignoreFailures>false</ignoreFailures>
<phantomJsExec>../path/to/phantomjsexecutable/..</phantomJsExec>
<!-- Optional -->
<includeLibsInDir>
<directory>${js.libs.include.dir}</directory>
<includes>
<include>**/*.js</include>
</includes>
</includeLibsInDir>
</configuration>
</plugin>
...
</plugins>
This Maven plugin works by convention. For each of your JavaScript files specified in the source directory, the plugin will search for the JavaScript test of the same name in the test directory, suffixed with 'Test'.
An example makes this clearer.
${jsSourceDirectory}/Foo.js
will be tested with ${jsTestDirectory}/FooTest.js
If a JavaScript file does not have a corresponding JavaScript test file, it will be skipped over.
Configuration Parameter | Required | Description |
---|---|---|
jsSourceDirectory | Yes | Specify the location in the Maven project where the JavaScript files reside. eg src/main/js |
jsTestDirectory | Yes | Specify the location in the Maven project where the JavaScript test files reside. eg src/test/js |
includeLibsInDir | No | Specify user defined libraries to include for your tests. [UsingLibraries See here for more information] |
ignoreFailures | No. Default is false | Specify whether to continue with the build if tests failed. |
phantomJsExec | No | Specify the path to the PhantomJs executable. See http://www.phantomjs.org to download. Assumes that phantomjs executable is in the system PATH if not specified |
test
Searches ${jsTestDirectory}
for test JavaScript files to run in PhantomJs & executes the QUnit tests. JavaScript test file is tested against JavaScript src file by convention described above.
Maven test lifecycle phase
JUnit readable xml output to target/junitxml/*.xml
generate-html
Searches ${jsTestDirectory}
for test JavaScript files. Wraps up these !JavaScript tests to produce QUnit HTML test files to execute in browser, just as you would normally do with QUnit test writing.
Maven test lifecycle phase
QUnit HTML files to target/qunit-html/*.html
, one HTML file per test Javascript file