I just got a basic setup up and running using QUnit, PhantomJS and js-testrunner.
This link helped some: jstest-runner-sample-project.
For configuration I used:
- js-testrunner 1.0.2
- QUnit 1.14.0
- PhantomJS v1.9.7
- plexus utils v1.5.7 (required by js-testrunner)
- jetty v8.1.15 (required by js-testrunner)
- jackson v1.9.13 (required by jetty)
The test required 4 files:
- JUnit Java test wrapper - FirstTest.java
- HTML test wrapper for QUnit - firstTest.html
- JavaScript file to test - tests.js
- log4j configuration (standard, basic configuration)
Here are the four files I used for this basic test:
FirstTest.java:
package delta;
import org.codehaus.jstestrunner.junit.JSTestSuiteRunner;
import org.junit.runner.RunWith;
@RunWith(JSTestSuiteRunner.class)
@JSTestSuiteRunner.Include(value="firstTest.html")
@JSTestSuiteRunner.ResourceBase({ "src-web/delta", "../lib" })
public class FirstTest {
}
firstTest.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<script type="text/javascript" src="script/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="script/qunit-1.14.0.js"></script>
<link type="text/css" rel="stylesheet" href="css/qunit-1.14.0.css"/>
<script type="text/javascript" src="tests.js"></script>
<title>firstTest</title>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>
tests.js:
/**
* Supports firstTest.html
*/
(function() {
var val;
module( "First Test", {
setup: function() {
val = 1
}
});
test( "hello test", function() {
ok( val == "1", "Passed!" );
});
}());
I invoked JUnit from within Eclipse, which uses the project root directory therefore requiring the paths to the test files.
After configuring the simple test I can execute them with standard Eclipse Run As->JUnit Test: