HTML and CSS Reference
In-Depth Information
integration servers, and it can use alternative assertion frameworks. Through plug-
ins, any other JavaScript testing framework can take advantage of the JsTestDriver
test runner, and at the time of writing, adapters for QUnit and YUI Test already
exist. This means tests can be written using YUI Test's assertions and syntax, but
run using JsTestDriver.
3.4.2 JsTestDriver Disadvantages
At the time of writing, JsTestDriver does not support any form of asynchronous
testing. As we will see in Chapter 12, Abstracting Browser Differences: Ajax, this isn't
necessarily a problem from a unit testing perspective, but it may limit the options
for integration tests, in which we want to fake as little as possible. It is possible that
asynchronous test support will be added to future versions of JsTestDriver.
Another disadvantage of JsTestDriver is that the JavaScript required to run tests
is slightly more advanced, and may cause a problem in old browsers. For instance,
by design, a browser that is to run JsTestDriver needs to support the XMLHttpRe-
quest object or similar (i.e., Internet Explorer's corresponding ActiveX object)
in order to communicate with the server. This means that browsers that don't sup-
port this object (older browsers, Internet Explorer before version 7 with ActiveX
disabled) cannot be tested with the JsTestDriver test runner. This problem can be
effectively circumvented, however, by using YUI Test to write tests, leaving the op-
tion of running them manually with the default test runner in any uncooperative
browser.
3.4.3 Setup
Installing and setting up JsTestDriver is slightly more involved than the average
in-browser testing framework; still, it will only take a few minutes. Also, the setup is
only required once. Any projects started after the fact are dirt simple to get running.
JsTestDriver requires Java to run both the server component and start test runs. I
won't give instructions on installing Java here, but most systems have Java installed
already. You can check if Java is installed by opening a shell and issue the java
-version command. If you don't have Java installed, you will find instructions
on java.com.
3.4.3.1 Download the Jar File
Once Java is set up, download the most recent JsTestDriver jar file from
http://code.google.com/p/js-test-driver/downloads/list. All the examples in this
book use version 1.2.1, be sure to use that version when following along with the
 
Search WWH ::




Custom Search