Java Reference
In-Depth Information
13.5
RhinoUnit versus JsUnit
Should you use RhinoUnit or JsUnit? The answer to this question is quite similar to
the HtmlUnit versus Selenium question, which we presented in the previous chapter.
The similarity is that both are free and open source.
The major difference between the two is that RhinoUnit emulates a web browser,
whereas JsUnit drives a real web browser process. When using JsUnit, the browser
itself provides support for JavaScript. In RhinoUnit, Java 6 or Apache BSF plus the
Mozilla Rhino 16 engine provide JavaScript support.
The RhinoUnit pros are that it's a 100 percent Java solution and is easy to integrate
in a build process. The JsUnit pros are that it drives native browsers and can manage a
farm of JsUnit test servers.
Use RhinoUnit when
Use RhinoUnit when your application is independent of operating system features
and browser-specific implementations of JavaScript, DOM, CSS, and so on.
Use JsUnit when
Use JsUnit when you require validation of specific browsers and operating systems,
especially if the application takes advantage of or depends on a browser's specific
implementation of JavaScript, DOM, CSS, and so on.
You've seen how to test client-side scripts with RhinoUnit and JsUnit. Next, we show
how you can check best practices with JSL int.
13.6
Checking best practices with JSLint
We now move on to checking our code for best practices with JSL int. 17 As we did for
the unit-testing script, we use scripts to define and run JSL int from Ant:
<scriptdef name="JSLintant" src="${JSLint.src}/JSLintant.js"
language="javascript">
<attribute name="options" />
<attribute name="JSLintpath" />
<element name="fileset" type="fileset" />
</scriptdef>
B
C
<target name="run-js-lint">
<JSLintant options="{eqeqeq : true, white: true, plusplus : false,
bitwise : true, evil: true, passfail: false}"
JSLintpath="${JSLint.src}/fullJSLint.js">
<fileset dir="${src.dir}" />
</JSLintant>
</target>
16
http://www.mozilla.org/rhino/
17
JSLint: http://www.JSLint.com/
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search