Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins + qUnit

How to easily integrate Jenkins with qUnit? I gonna use real browser (like firefox and chrome) to run tests. My server runs on RedHat 6.1 Linux. I think I have all needed plugins/libraries but I still don't know how to make it working. I'm working with Jenkins 1st time (on server side).

//Edit:

It would be wonderful if someone can share idea how to build coverage report too.

Thanks in advance :).

like image 852
Oskar Avatar asked Oct 13 '11 15:10

Oskar


3 Answers

Saying Jenkins and QUnit is only part of the puzzle. You still need a web browser and a way to get a JUnit style XML file from the QUnit results on to disk. While there is Selenium and Webdriver for controlling numerous browsers, the easiest way to get started is to use PhantomJS (http://phantomjs.org/). PhantomJS is a headless webkit based browser meant just for tasks like this.

If you browse the "Test Frameworks" sections of this page ( http://code.google.com/p/phantomjs/wiki/WhoUsesPhantomJS ) you will see several scripts for running QUnit (some with JSCoverage support). The phantomjs-jscoverage-qunit script looks like it will hit all the major points you want to hit, as does United. Both look like they will require some fiddling to get them going though.

Alas, I haven't discovered any method for running QUnit tests and getting JUnit output for either Selenium, WebDriver, or PhantomJS that will just work without modification.

EDIT: Now several months later, it have become clear to me that webdriver is the future of Selenium (it probably should have been clear to me back then, but it wasn't). Also, PhantomJS now works with WebDriver via GhostDriver, so supporting only WebDriver and choosing PhantomJS as a target is probably the best advice going forward.

like image 192
Joshua D. Boyd Avatar answered Oct 23 '22 14:10

Joshua D. Boyd


It's been over a year since this question was posted, but there is a Jenkins plugin for TestSwarm. My layman's understanding is that you can use TestSwarm run your QUnit tests continuously across all of the major browsers. It is open sourced on GitHub.

like image 34
Delicia Brummitt Avatar answered Oct 23 '22 13:10

Delicia Brummitt


Disclosure: I'm contributor of the Arquillian project.

You can use the Arquillian Qunit Extension open source extension to execute your QUnit tests on Jenkins. In general, Arquillian Qunit Extension can be easily used in continuous integration environments. On this GitHub repo you can find a real example of how Arquillian Qunit Extension can be used to execute QUnit tests on Travis CI headless machines.

Arquillian is a JBoss Community project.

Arquillian Qunit Extension is is an Arquillian extension which automates the QUnit JavaScript testing. Arquillian Qunit Extension integrates transparently with the JUnit testing framework.

You can find more information on this README file. In addition, there is a showcase which can be executed through Maven and shows how to setup your test case.

Using this extension, you have the option to deploy an archive during the QUnit test executions and/or execute one or more QUnit Test Suites in a single execution. Furthermore you can define the QUnit Test Suite execution order using the @InSequence annotation.

For example, assume that you want to execute two QUnit Test Suites (qunit-tests-ajax.html and qunit-tests-dom.html) and that your QUnit tests included in these test suites perform Ajax requests to a Web Service. Apparently, you need this Web Service to be on host while the tests are executed. Arquillian can automatically perform the deployment of the Web Service to a container. In a such case your Arquillian test case will look like:

 @RunWith(QUnitRunner.class)
 @QUnitResources("src/test/resources/assets")
 public class QUnitRunnerTestCase {

     private static final String DEPLOYMENT = "src/test/resources/archives/ticket-monster.war";

     /**
      * Creates the Archive which will be finally deployed on the AS.
      *
      * @return Archive<?>
      */
     @Deployment()
     public static Archive<?> createDeployment() {
         return ShrinkWrap.createFromZipFile(WebArchive.class, new File(DEPLOYMENT));
     }

     /**
      * Execute the qunit-tests-ajax.html QUnit Test Suite.
      */
     @QUnitTest("tests/ticketmonster/qunit-tests-ajax.html")
     @InSequence(1)
     public void qunitAjaxTests() {
         // empty body - only the annotations are used
     }

     /**
      * Execute the qunit-random-tests.html QUnit Test Suite.
      */
     @QUnitTest("tests/ticketmonster/qunit-random-tests.html")
     @InSequence(2)
     public void qunitRandomTests() {
         // empty body - only the annotations are used
     }
}
like image 1
Apostolos Emmanouilidis Avatar answered Oct 23 '22 14:10

Apostolos Emmanouilidis