开发者

Continuous integration / Testing of Javascript code against different browsers

I am writing a set of functions in Javascript meant to be executed inside a browser (no server-side Javascript).

How to run unit and perfomance tests agains them in different browsers, and keep track 开发者_JAVA技巧of the results for every build?

  • Tests should be executed within a browser
  • Test results should be produced as a stand alone text or html file
  • Target browsers are Internet Explorer 7 and 8, latest Firefox, latest Chrome, latest Safari
  • I am free to setup a dedicated CI server and virtual machines if needed


I have been using Jasmine framework for the testing and JSTestDriver. I had also set up both Hudson and TeamCity for CI as part of evaluation, though eventually settled on TeamCity.

Jasmine is a very nice BDD framework, which also provides mocking and stubbing functionality.

JSTestDriver server allows any browser to attach to it, whether local, or remote, as Vojta has already pointed out. I have been able to connect browsers from Windows and MAC machines for example, and also iPhone ... it is quite possible to connect other mobile browsers, if mobile development tickles your fancy. JSTestDriver will produce JUnit XML results files that either Hudson or TeamCity will be able to parse and report upon.

As Vojta also pointed out, an Eclipse plugin is available for JSTestDriver. I have recently moved over to WebStorm 1.0 and now 2.0 (IDE from JetBrains), and a plugin exists for this IDE as well, albeit somewhat buggy. WebStorm is excellent, btw, as far as JavaScript development is concerned.

We are also writing server-side JS code, and Jasmine has worked fine here as well.

I have installed and configured JsTestDriver/TeamCity on the Amazon cloud and I am able to run Jasmine tests headlessly, for example.

In short, between the 3 solutions (Jasmine, JSTestDriver, and TeamCity), tons of plugins/adapters/recipes exist that allow any number of setups or configurations. That is not to say other combinations will not work ... simply, for me, this combinations has proven itself thus far.


Hi you may take a look a JQunit, a javascript unit testing framework based on JQuery. Available here http://code.google.com/p/jqunit/


Jasmine (http://pivotal.github.com/jasmine) is a dependency-free BDD framework for testing JavaScript.

It would be pretty easy to use Jasmine & the Jasmine Ruby gem to setup a matrix of runs against the different browsers (Selenium drives the browser in the gem) and reporting them via your CI as you suggest. Should be straightforward.


I'm using JsTestDriver for JS developing. It's a test runner (not unit test framework), so you can use it together with Jasmine, or QUnit.

You simply start a server and capture browsers (could be remote browser as well !) and then run tests on all these browsers through command line.

There is a nice plugin for eclipse as well.

For more information, how to set up continuous build environment, see http://code.google.com/p/js-test-driver/wiki/ContinuousBuild

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜