I have a webapp build plan running on a Continuous Integration system (Atlassian Bamboo 2.5). I need to incorporate QUnit-based JavaScript unit tests into the build plan so that on each build, the Javascript tests would be run and Bamboo would interpret the test results.
Preferably I would like to be able to make the build process "standalone" so that no connections to external servers would be required. Good ideas on how to accomplish this? The CI system running the build process is on an Ubuntu Linux server.
As I managed to come up with a solution myself, I thought it would be a good idea to share it. The approach might not be flawless, but it's the first one that seemed to work. Feel free to post improvements and suggestions.
What I did in a nutshell:
I will next go through the more detailed phases. This is what my my directory structure ended up looking like:
On the build server:
apt-get install Xvfb
)apt-get install firefox
)Into your application to be built:
equiv.js
andQUnitAdapter.js
jsTestDriver.conf
):Create a script file for running the unit tests and generating test results (example in Bash,
run_js_tests.sh
):Create an Ant target that calls the script:
Finally, tell the Bamboo build plan to both invoke the
test
target and look for JUnit test results. Here the default"**/test-reports/*.xml"
will do fine.As an alternative, you could also try TestSwarm. I've got it up and running using QUnit to run my JS tests.
JS Test Runner is a pretty good solution. It uses PhantomJS and QUnit.
For anyone interested in running their Jasmine BDD specs headlessly in maven, you might be interested in the jasmine-maven-plugin I maintain:
http://github.com/searls/jasmine-maven-plugin
I've played around with a number of solutions over the past year but I didn't find anything in the ballpark of Karma (formerly testacular). Give it a try
http://karma-runner.github.com/
I have used maven and junit to call rhino. It is not elegant, but I use it to test basic services and utility code.
It requires mocking unsupported classes, like XHR with Java libraries.
I found that it is best code everything in javascript (tests, etc) and only use junit for build organization and a hook into the CI.
I'd like to see if JsTestDriver can do it though. Or mocha w/ a junit reporter.