javascript unit testing
TRANSCRIPT
Christian Johansen
http://cjohansen.no/enhttp://twitter.com/cjno
http://gitorious.org/~cjohansen
http://github.com/cjohansen
Table of ContentsWhy unit test JavaScript?
How to unit test JavaScript?
Brief example of unit testing chat client
Which version?•IE: 6, 7, 8 ?•Firefox: 3.0, 3.5, 3.6, 3.7 ?•Safari: 4, 3.1?•Opera 10.50, 10.10, 10.0?
YUI TestPart of the YUI Framework
Can test any code
Typical in-browser test framework
http://developer.yahoo.com/yui/3/test/
The Good PartsRun in any browser
Simple to get started(don't even have to download YUI)
Many high-level assertions
The Bad PartsRequires HTML fixture
Requires internet connection(can be fixed)
Does not solve the scaling problem
Similar offeringsQUnithttp://docs.jquery.com/QUnit
JsUnitTest (Prototype.js)http://jsunittest.com/
JsUnit (Since 2001)http://jsunit.net/
JSpecBDD style testing framework
Custom grammar(Ruby-like, optional)
Run in browser, or headlessly
http://visionmedia.github.com/jspec/
The Bad PartsRhino + env.js = Fully emulated
Browser launching still manual
Ruby-like DSL (although optional)
The JsTestDriver WayTests execute in browsers
Browsers listen for tests
Browsers can run locally or remote
Execute in multiple browsers simultaneously
Running Tests
Issue test runs from command line...or from IDE (Eclipse + Idea)
View results in command line, IDE
More Good PartsCan integrate runner with other assertion frameworks (QUnit, YIU Test++)
Coverage tool
JUnit compatible XML output