I've been trying to get Jenkins to display a JUnit report of a sample js project which i am testing with QUnit. I have literally scoured the internet for bits and pieces and so far, Running QUnit tests with Jenkins and Apache Ant? is the most helpful post that i have found.
I can confirm that:
- The user has sufficient privileges to write to disk
PhantomJS works headless from the shell when i write something along the lines of:
[user@myserver PhantomJS]$ phantomjs phantomjs-runner/runner.js web/index.html
And shows:
Took 8ms to run 6 tests. 6 passed, 0 failed.
Qunit does work and provides test results when executed in a browser
Still i cannot get the report.xml to generate in order to feed it into Jenkins. Below is the target i have added to my build.xml file:
<target name="qunit" description="runs QUnit tests using PhantomJS">
<!-- QUnit Javascript Unit Tests -->
<echo message="Executing QUnit Javascript Unit Tests..."/>
<apply executable="/usr/local/CI/phantomjs/bin/phantomjs" >
<arg value="/usr/local/CI/phantomjs-runner/runner.js" />
<arg line="--qunit /usr/local/CI/jenkins/workspace/PhantomJS/web/js/qunit-1.17.1.js --tests /usr/local/CI/jenkins/workspace/PhantomJS/web/index.html --junit /usr/local/CI/jenkins/workspace/PhantomJS/test-results/report.xml" />
<fileset dir="${basedir}/web/" includes="/js/prettydate.js" />
<srcfile/>
</apply>
<echo message="Tests complete..."/>
</target>
Compiling the project in Jenkins gives me the following output:
? PhantomJS/result.xml ? PhantomJS/test-results Using locally configured password for connection to :pserver:user@server:/cvsroot cvs rlog -S -d18 Feb 2015 15:49:54 +0000<18 Feb 2015 15:51:40 +0000 QUnit_Jenkins [PhantomJS] $ /usr/local/CI/ant/bin/ant qunit Buildfile: /usr/local/CI/jenkins/workspace/PhantomJS/build.xml
qunit: [echo] Executing QUnit Javascript Unit Tests... [echo] Tests complete...
BUILD SUCCESSFUL Total time: 0 seconds Recording test results Test reports were found but none of them are new. Did tests run? For example, /usr/local/CI/jenkins/workspace/PhantomJS/test-results/report.xml is 4 hr 18 min old
Build step 'Publish JUnit test result report' changed build result to FAILURE Finished: FAILURE
As you may notice, jenkins can't find an updated report.xml file because there simply isn't one getting generated.
Can you observe any mistakes in my build.xml? If not, any ideas, hints that would assist me in getting the result.xml file generated?