see: http://stackoverflow.com/questions/300855/looking-for-a-better-javascript-unit-test-tool
Buster.js
Very similar server/client concept as JsTestDriver (see further down). Except that the server is built with JavaScript (node.js) instead of Java, and the API follows JS best practices to a much higher degree.
A browser JavaScript testing toolkit. It does browser testing with browser automation (think JsTestDriver), qunit style static html page testing, testing in headless browsers (phantomjs, jsdom, ...), and more. Take a look at the overview!A Node.js testing toolkit. You get the same test case library, assertion library, etc. This is also great for hybrid browser and Node.js code. Write your test case with Buster.JS and run it both in Node.js and in a real browser.
Screencast: Buster.js Getting started (2:45)
pros:
- Uses node.js, so compatible with Win/OS X/Linux
- Run tests from browser or headless with PhantomJS (soon)
- Run on multiple clients at once
- Supports NodeJS testing
- Don't need to run server/clients on development computer (no need for IE)
- Run tests from command line (can be integrated in ant/maven) Write tests xUnit or BDD style
- Supports multiple JavaScript test frameworks
- Defer tests instead of commenting them out
- SinonJS built in
- Auto-run tests on save
- Proxies requests cross-domain
- Possible to customize:
- Extend it to wrap other test-frameworks (JsTestDriver built in)
- Your own assertions/refutes
- Reporters (xunit XML, traditional dots, specification, tap, teamcity and more built in)
- Customize/replace the HTML that is used to run the browser-tests
- TextMate and Emacs integration
cons:
- Stil in beta, so can be buggy
- No plugin for Eclipse/IntelliJ (yet)
- Doesn't group results by os/browser/version like TestSwarm *. It does however print out the browser name and version in the test results.
- No history of previous test results like TestSwarm *
- Doesn't fully work on windows as of nov 2012
* TestSwarm is also a Continuos Integration server, while you need a separate CI server for Buster.js. It does however output xUnit XML reports, so it should be easy to integrate with Hudson, Bamboo or other CI servers.
Testacular
Again, very similar server/client concept as JsTestDriver (see further down). Like Buster.js the server is built with JavaScript (node.js).
Screencast: Testacular Getting started
pros:
- Uses node.js, so compatible with Win/OS X/Linux
- Run tests from browser or headless with PhantomJS
- Run on multiple clients at once
- Option to launch, capture, and automatically shutdown browsers
- Option to run server/clients on development computer or separately
- Run tests from command line (can be integrated in ant/maven)
- Write tests xUnit or BDD style
- Supports multiple JavaScript test frameworks
- Auto-run tests on save
- Proxies requests cross-domain
- Possible to customize:
- Extend it to wrap other test-frameworks (Jasmine, Mocha, QUnit built-in)
- Your own assertions/refutes
- Reporters
- Browser Launchers
- Plugin for WebStorm
cons:
- Does not supports NodeJS testing
- No plugin for Eclipse (yet)
- No history of previous test results
TestSwarm
John Resig (jQuery) has created a tool for distributed JavaScript testing, TestSwarm. Mainly for open source JavaScript projects, but TestSwarm is open source, so you can set up a server yourself for corporate testing. Although this might require that you to do some modifications.
pros:
- Continuos integration server for JavaScript
- Supports all major browsers/operating systems
- Run on multiple clients at once
- Don't need to run server/clients on development computer (no need for IE)
- Automatic run tests on all clients when you commit something (or whenever you modify the script to run the tests)
- Show history of test results pr commit
- Supports multiple JavaScript test frameworks
- Have test results for OS and browser versions
- Crowdsource to test in a multitude of browsers
cons:
- Can not break your build through ant/maven
- Don't notice the test fail before commit
- No IDEplug-in
TestSwarm architecture:
JsTestDriver
Some people at Google have also started on a distributed JavaScript tool, JsTestDriver. It is similar to TestSwarm, that it has a server, and clients connected. But it also has support for running tests from command line and plugins for Eclipse and IntelliJ!
pros:
- Supports all major browsers/operating systems
- Run on multiple clients at once
- Don't need to run server/clients on development computer (no need for IE)
- Run tests from command line (jar) (can be integrated in ant/maven)
- Eclipse plugin
- IntelliJ plugin
- Supports multiple JavaScript test frameworks
cons:
- Doesn't show results for os or browser version. Only browser names. It does however print out the version in the test results.
- No history of previous test results
- Very low project activity
Overview of how JsTestDriver works at runtime:
Eclipse plugin screenshot:
Short intro video: http://www.youtube.com/watch?v=V4wYrR6t5gE
YUI Yeti
Yahoo now has their own JavaScript test run server, Yeti. Built with node.js. It should be able to run your existing YUI-tests as they are, and works in multiple browsers. Since it runs from the command-line I guess it's mostly similar to JsTestDriver.
Announcement from August 25th 2010: http://www.yuiblog.com/blog/2010/08/25/introducing-yeti-the-yui-easy-testing-interface/
If you have experience with this test-runner, please contribute with more info :)
Project home: http://yuilibrary.com/projects/yeti/
Jasmine
This is a test-runner that might interest developers familiar with Ruby or Ruby on Rails. The syntax is based on RSpec that's used for testing in Rails projects.
Jasmine is a behavior-driven development framework for testing your JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM.
If you have experience with this test-runner, please contribute with more info :)
Project home: https://github.com/pivotal/jasmine/
QUnit
QUnit focuses on testing JavaScript in the browser, while providing as much convenience to the developer as possible. Blurb from the site:
QUnit is a powerful, easy-to-use JavaScript unit test suite. It's used by the jQuery, jQuery UI and jQuery Mobile projects and is capable of testing any generic JavaScript code
QUnit shares some history with TestSwarm (above):
QUnit was originally developed by John Resig as part of jQuery. In 2008 it got its own home, name and API documentation, allowing others to use it for their unit testing as well. At the time it still dependended on jQuery. A rewrite in 2009 fixed that, now QUnit runs completelty standalone. QUnit's assertion methods follow the CommonJS Unit Testing specification, which was to some degree influenced by QUnit.
Project home: http://qunitjs.com/
Sinon
Another great tool is sinon.js by Christian Johansen, the author of Test-Driven JavaScript Development. Best described by himself:
Standalone test spies, stubs and mocks for JavaScript. No dependencies, works with any unit testing framework.
评论
发表评论