HTML and CSS Reference
In-Depth Information
3.3.1 Crosscheck
Crosscheck is one of the early headless testing frameworks. It provides a Java backed
emulation of Internet Explorer 6 and Firefox versions 1.0 and 1.5. Needless to say,
Crosscheck is lagging behind, and its choice of browsers are unlikely to help develop
applications for 2010. Crosscheck offers JavaScript unit tests much like that of YUI
Test, the difference being that they can be run on the command line with the
Crosscheck jar file rather than in a browser.
3.3.2 Rhino and env.js
env.js is a library originally developed by John Resig, creator of the jQuery
JavaScript framework. It offers an implementation of the browser (i.e., BOM) and
DOM APIs on top of Rhino, Mozilla's Java implementation of JavaScript. Using
the env.js library together with Rhino means we can load and run in-browser tests
on the command line.
3.3.3 The Issue with Headless Test Runners
Although the idea of running tests on the command line is exciting, I fail to recognize
the power of running tests in an environment where production code will never run.
Not only are the browser environment and DOM emulations, but the JavaScript
engine (usually Rhino) is an altogether different one as well.
Relying on a testing framework that simply emulates the browser is bad for a
few reasons. For one, it means tests can only be run in browsers that are emulated
by the testing framework, or, as is the case for solutions using Rhino and env.js, in
an alternate browser and DOM implementation altogether. Limiting the available
testing targets is not an ideal feature of a testing framework and is unlikely to help
write cross-browser JavaScript. Second, an emulation will never match whatever it
is emulating perfectly. Microsoft probably proved this best by providing an Internet
Explorer 7 emulation mode in IE8, which is in fact not an exact match of IE7.
Luckily, we can get the best from both worlds, as we will see next, in Section 3.4,
One Test Runner to Rule Them All.
3.4 One Test Runner to Rule Them All
The problem with in-browser testing frameworks is that they can be cumbersome to
work with, especially in a test-driven development setting where we need to run tests
continuously and integrated into the workflow. Additionally, testing on a wide array
of platform/browser combinations can entail quite a bit of manual work. Headless
 
 
Search WWH ::




Custom Search