JavaScript unit testing and continuous integration 2011
Most of the existing questions about unit testing JavaScript code and integrating it into a continuous integration environment seem to date back to the dawn of time (or at least 2008 or 2009 :) ). Even a recent one is from about a year and a half ago:
Running JavaScript unit tests headlessly in a Continuous Integration build
Before I launch into开发者_如何学Python trying to use js-test-driver to build tests and integrate them into Jenkins (nee Hudson), is this still the best approach in 2011?
We've got code that uses JavaScript and jQuery, Lawnchair, lccache, Fancybox, and more. I don't think we have to test all of it, but it would be nice if we could build tests for a reasonable subset. Bonus points if the solution is happy with backbone.js. It's looking more and more likely as time wears on.
After some further looking into this, we're going to give Jasmine BDD a try for our testing. It's featured in the PeepCode videos on Backbone.js as well as this excellent article series about testing Backbone.js using Jasmine:
- http://tinnedfruit.com/2011/03/03/testing-backbone-apps-with-jasmine-sinon.html
- http://tinnedfruit.com/2011/03/25/testing-backbone-apps-with-jasmine-sinon-2.html
- http://tinnedfruit.com/2011/04/26/testing-backbone-apps-with-jasmine-sinon-3.html
If we go down this route it appears we may have to combine it with JsTestDriver so we can plug the whole mess into Jenkins.
You could run Selenium tests together with Jenkins.
For reference in case someone stumbles on this later on: there is also TestSwarm (used by the JQuery team) and Buster.js (up and coming JSTestDriver replacement)
精彩评论