问题
This is my first sof post so forgive my format and organization of thought. I've made a great effort to solve my problem before posting this. Part of my issue could be lack of knowledge with packages in Ubuntu or Node.js so please guide me.
I'm trying to create a XUnit xml file for Jenkins from QUnit tests for a Node.js application. I don't have the ability to run a browser or even a headless browser, also don't understand why I'd need one since the Node.js code doesn't deal with the browser.
I've been searching all over and have only been successful using qunit-tap and 'prove' to create an XML file. Prove required downloading a formatter which was a perl file. We are trying to prevent using perl stuff.
My system is an Ubuntu VM. This is a task for work and my boss is asking for the minimal amount of packages and dependencies. Our Node.js server is accepting web socket requests and passing messages back and forth with a legacy system written in php.
QUnit's output seems to be a pretty print format, in a table, when I run my tests in the console. It would be amazing to just get that into a flatter form with a flag!
Thanks in advance!
回答1:
Well, for NodeJS you can go with Grunt and grunt-contrib-qunit, though I would recommend the following approach:
- Leverage JUnit Logger (https://github.com/jquery/qunit-reporter-junit) plugin for JUnit compatible report.
- Comment out console.log output in the PhantomJS Runner https://github.com/jquery/qunit/tree/master/addons/phantomjs to mute non-XML output produced by the runner
- Assign a task for Apache Ant build script:
<target name="qunit" description="runs QUnit tests using PhantomJS"> <echo message="Executing QUnit Javascript Unit Tests..."/> <exec executable="/usr/local/bin/phantomjs" output="./build/qunit/qunit-results.xml"> <arg value="./vendors/Runner/runner-muted.js" /> <arg value="test-runner.html" /> </exec> </target>
Jenkins shall look for the report in ./build/qunit/qunit-results.xml
回答2:
ditto, above answer good
use the junit report out and connect it to the standard jenkins unit testing plugin -> http://wiki.jenkins-ci.org/display/JENKINS/xUnit+Plugin
for nice easy to configure self-installed nodejs on the machine, i have to recommend the excellent -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
for jshint/csslint reports, i found the https://wiki.jenkins-ci.org/display/JENKINS/Checkstyle+Plugin plugin very nice, jshint and csslint both output to this
jshint : {
options : {
reporter : 'checkstyle',
reporterOutput : 'reports/jshint.xml',
},
src : "..."
},
csslint : {
strict : {
options : {
formatters : [{
id : 'checkstyle-xml',
dest : 'reports/csslint.xml'
}],
csslintrc: '.csslintrc'
},
src : [...],
},
},
来源:https://stackoverflow.com/questions/15708039/integrating-node-js-with-qunit-to-jenkins