Having issues creating a report.xml file for QUnit + PhantomJS + Jenkins
I have found a solution to my answer by taking the following steps:
1) added <script src="js/qunit-reporter-junit.js"></script>
as it is required to generate the report. Ensure you also have the qunit.js library included also. I used qunit-1.17.1.js
2) I placed the following code in the html file that tests my js code:
<script>QUnit.jUnitReport = function(report) { console.log(report.xml) };</script>
3) I added the Ant code in my build.xml file:
<target name="build" description="runs QUnit tests using PhantomJS"> <!-- Clean up output directory --> <delete dir="./build/qunit"/> <mkdir dir="./build/qunit"/> <!-- QUnit Javascript Unit Tests --> <echo message="Executing QUnit Javascript Unit Tests..."/> <exec executable="/usr/local/CI/phantomjs/bin/phantomjs" output="./build/qunit/qunit-results.xml"> <arg value="/usr/local/CI/phantomjs-runner/runner-muted.js"/> <arg value="./web/index.html"/> </exec> </target>
You will observe that i changed the name of runner.js to runner-muted.js This is so, because i have made changes to runner.js to not include its output to the xml file, as this makes it unreadable by jenkins. To do so:
- cp /usr/local/CI/phantomjs-runner/runner.js /usr/local/CI/phantomjs-runner/runner-muted.js
- Find and comment out console.log occurrences found under QUnit.done and QUnit.testDone to mute the runner from displaying its own test run results.
- Ensure that in Jenkins you have selected the correct path to the generated xml file.
I hope this helps any of you trying to get it to work