Java Reference
In-Depth Information
JSLint tip
When you invoke the
JSLintant
Ant script, make sure you point the
JSLintpath
argument to the location of the full JSLint.js file, for example:
JSLintpath="${JSLint.src}/fullJSLint.js"
We start by defining an Ant script for
JSL
int
b
and then call the script
C
and pass it
the source location to our JavaScript library directory.
You run this example script by typing
ant
on the command line in the ch13-ajax-
rhinounit directory for this chapter example, which displays the results shown in list-
ing 13.9.
Listing 13.9
Ant build results
Buildfile: build.xml
run-unit-tests:
[rhinounit] Testsuite: test-all-valid.js
[rhinounit] Tests run: 17, Failures: 0, Errors: 0
[rhinounit]
[rhinounit] Testsuite: test-example.js
[rhinounit] Tests run: 2, Failures: 0, Errors: 0
[rhinounit]
run-js-lint:
[JSLintant] Attribute options = {eqeqeq : true, white: true, plusplus :
false, bitwise : true, evil: true, passfail: false}
[JSLintant] JSLint: No problems found in ch13-
rhinounit\src\main\webapp\factorial.js
run-all-tests:
BUILD SUCCESSFUL
Total time: 0 seconds
JSL
int is quite verbose and comprehensive in its output; please see the
JSL
int
18
website
for details.
We started by looking at functional testing from the client perspective. Next, we
dove into testing one of the underlying building blocks of an Ajax application: client-
side scripts with RhinoUnit and JsUnit. We also checked these scripts for best practices
with
JSL
int. Next, we move to the server side and another building block: testing
server-side services with HttpClient.
18