There is some literature out there on this, but parsing through it was super-hard, especially for a person like me who's a newb to all these TDD contraptions. For instance, this very excellent link shows you how to set up headless testing, but is vague when it comes to Hudson integration: http://www.build-doctor.com/2010/12/08/javascript-bdd-jasmine/
So assuming you have Jasmine working in your browser, do the following:
1) Go to the Larry Myers' Jasmine-Reporters repo on github, and clone/download the repository you find here: https://github.com/larrymyers/jasmine-reporters
2) Set up a lib folder in the same directory as your SpecRunner.html file (this is the html file that references all the scripts Jasmine will be using for testing; you have one of these if you got Jasmine to run in a browser), with the following files in it:
* js.jar
* env.rhino.1.2.js
* jasmine.console_reporter.js
* jasmine.junit_reporter.js
* envjs.bootstrap.js
3) To SpecRunner.html, between the script tags that contain the jasmine reporters, add the JUnitXMLReporter() as follows:
jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter());
4) Run the following command from terminal in the same directory as the SpecRunner.html file:
java -jar lib/js.jar -opt -1 lib/envjs.bootstrap.js SpecRunner.html
Et voila! That should produce the headless testing you needed. Now for the Hudson integration (I'm assuming Jenkins has something similar) do the following:
1) Navigate to <project-name>/Configure.
2) Under the 'Build' heading, click 'Add Build Step', and select 'Execute Shell'.
3) Add the following lines to the textbox that shows up, replacing <dir-containing-specrunner> with the appropriate path. $WORKSPACE is simply a predefined variable that contains the path to the Hudson workspace:
#!/bin/sh
cd $WORKSPACE/<dir-containing-specrunner>
java -jar lib/js.jar -opt -1 lib/envjs.bootstrap.js SpecRunner.html
4) Under the 'Post-Build Actions' heading, select 'Publish JUnit test result report'
5) In the field that appears, enter the following:
<dir-containing-specrunner>/TEST-*.xml
6) Save, and tell Hudson/Jenkins to do a build. The console output should show your tests being run, and Hudson will do a report on them. :)
Special thanks to Zac Thompson over at Stack Overflow, for helping me with steps 4-5 of the Hudson integration part. See: http://stackoverflow.com/questions/7735149/parsing-junit-xml-with-hudson/7735455#7735455
Hope this is useful!
So assuming you have Jasmine working in your browser, do the following:
1) Go to the Larry Myers' Jasmine-Reporters repo on github, and clone/download the repository you find here: https://github.com/larrymyers/jasmine-reporters
2) Set up a lib folder in the same directory as your SpecRunner.html file (this is the html file that references all the scripts Jasmine will be using for testing; you have one of these if you got Jasmine to run in a browser), with the following files in it:
* js.jar
* env.rhino.1.2.js
* jasmine.console_reporter.js
* jasmine.junit_reporter.js
* envjs.bootstrap.js
3) To SpecRunner.html, between the script tags that contain the jasmine reporters, add the JUnitXMLReporter() as follows:
jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter());
4) Run the following command from terminal in the same directory as the SpecRunner.html file:
java -jar lib/js.jar -opt -1 lib/envjs.bootstrap.js SpecRunner.html
Et voila! That should produce the headless testing you needed. Now for the Hudson integration (I'm assuming Jenkins has something similar) do the following:
1) Navigate to <project-name>/Configure.
2) Under the 'Build' heading, click 'Add Build Step', and select 'Execute Shell'.
3) Add the following lines to the textbox that shows up, replacing <dir-containing-specrunner> with the appropriate path. $WORKSPACE is simply a predefined variable that contains the path to the Hudson workspace:
#!/bin/sh
cd $WORKSPACE/<dir-containing-specrunner>
java -jar lib/js.jar -opt -1 lib/envjs.bootstrap.js SpecRunner.html
4) Under the 'Post-Build Actions' heading, select 'Publish JUnit test result report'
5) In the field that appears, enter the following:
<dir-containing-specrunner>/TEST-*.xml
6) Save, and tell Hudson/Jenkins to do a build. The console output should show your tests being run, and Hudson will do a report on them. :)
Special thanks to Zac Thompson over at Stack Overflow, for helping me with steps 4-5 of the Hudson integration part. See: http://stackoverflow.com/questions/7735149/parsing-junit-xml-with-hudson/7735455#7735455
Hope this is useful!