Is it possible to execute my QUnit (javascript) unit tests from Jenkins? My build script is Apache Ant. Would Jenkins execute this as a separate Build Step, or would I need to add something in the config of my Ant build script?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
If I understand your setup correctly, you can run Ant build step providing it with the location of your
build.xml
, top-level target, and-D
parameters (if any). This may be of some help.I've written an Ant task specifically for this
https://github.com/philmander/ant-jstestrunner
Qunit itself now maintains a phantomjs runner:
https://github.com/jquery/qunit/tree/master/addons/phantomjs
So assuming you've already installed phantomjs, grab runner.js from the link above (or get it using bower/whatever js package manager), put it somewhere jenkins can find it, and then use:
It gives minimal output like this:
Or like this if it fails:
No junit-xml integration, but at least it returns an error code if it fails, so it'll fail the build in jenkins...
So, I have finally managed to figure this out.
Here's my end-to-end implementation:
Install PhantomJS (http://phantomjs.org/) - I installed this in my build/tools folder
Install the PhantomJS QUnit Runner script (https://gist.github.com/1588423) - also installed this in my build/tools folder
Added the following target to my build.xml file:
Under my Jenkins project config, I now invoke Ant with "minify qunit"
I point Jenkins to the JUnit-style output XML file
And, here is the workflow:
PS: At the moment, you have to manually delete the JUnit-type XML output file. I will fix this later.
PS: Download the customized qunit.js (https://gist.github.com/2488794)