Skip to content
This repository has been archived by the owner on Nov 23, 2018. It is now read-only.

Setting up the Qunit task for use with Jenkins

roblarsen edited this page Jan 29, 2013 · 3 revisions

Based on the work done in #60 we have this:

  1. Install phantomjs (http://phantomjs.org/) in your build/tools
  2. Install the Phantom QUnit Runner script (https://gist.github.com/1588423) in you build tools folder
  3. drop the qunit script in you build tools folder
  4. update the following properties in project.properties
# https://github.com/h5bp/ant-build-script/wiki/Setting-up-the-Qunit-task-for-use-with-Jenkins
# the path to your phantomjs binary. It should live in ${dir.build.tools}
 tool.phantomJS = phantomjs-1.8.1-windows/phantomjs.exe
# the name of your qunit.js file for PhantomJS
 tool.qunit.js = qunit-1.11.0.js
#the location of qunit-runner for PhantomJS
 tool.qunitrunner.js = qunit-runner.js
# the location of your tests
 dir.tests           = tests
  1. Add the qunit task to whichever flavor of build you commonly run, for example, to add it to the default do:
    <target name="-build.production"
          depends="-intro,
                   -usemin,
                   -js.all.minify,
                   -js.main.concat,
                   -js.scripts.concat,
                   -css,
                   -htmlclean,
                   -imagespng,
                   -imagesjpg,
                   -copy,
                   -jsdoc3,
                   -qunit"/>
  1. Configure Jenkins to use our newly enhanced task (this example would just be ant build since it's the default.)

  2. Point Jenkins to the JUnit-style output XML file

The assumption is that you will have the wherewithal to move these things around and to edit the qunit task itself. This is a functional example of one way it can work.

    <target name="qunit" description="runs QUnit tests using PhantomJS">
      <apply executable="${basedir}/${dir.build.tools}/${tool.phantomJS}" >
        <fileset dir="${dir.tests}"/>
        <arg value="${basedir}/${dir.build.tools}/${tool.qunitrunner.js}" />
        <arg value="--qunit"/>
        <arg path="${basedir}/${dir.build.tools}/${tool.qunit.js}" />
        <arg value="--tests"/>
        <arg path="${dir.tests}" />
        <srcfile/>
      </apply>
    </target>