Java Reference
In-Depth Information
paths. Next, we define logsDirectory D to hold the directory location for test report
XML files. The property timeoutSeconds E is a timeout in seconds to wait for a test
run to complete; if absent, the default value is 60 seconds. The url property F defines
which test runner to use and which test or test suite it should invoke. It's worth breaking
down this URL into its component parts. The example URL is http: // localhost:8080/
jsunit/jsunit/testRunner.html?testPage= http: // localhost:8080/jsunit/src/test/webapp/
jsUnitTestSuite.html.
The URL starts with http: // localhost:8080 be cause we're running our tests locally.
The next segment, jsunit, specifies the jsunit servlet and from there the location to
the JsUnit stock test runner, relative to build.xml, which is jsunit/testRunner.html.
All of this yields the first part of the URL : http: // localhost:8080/jsunit/jsunit/test-
Runner.html. The testPage URL parameter points to the test page or suite page to
run. It too starts with the same local server plus the jsunit servlet prefix and is fol-
lowed by the path to the test suite page relative to where the test is run. Put it all
together and we have the complete URL .
Next, we give Ant all of the JAR files needed to run JsUnit G , and then we can pro-
ceed to running our test with the target standalone_test H , which we invoke from
the command line in the build.xml directory with a simple call to Ant by typing the
following in a console:
ant standalone_test
Ant starts, and you'll see the web browser open, run the tests in the test runner page,
and close. You'll also see a couple of pages of Ant and JsUnit output on the console
detailing the test run, too much to reproduce here. We can look for the next-to-last
line of Ant output for the familiar BUILD SUCCESSFUL message.
You can even add to your test run the JsUnit self-tests as a sanity check by adding
the target jsunit_self_test I to your Ant invocation:
ant jsunit_self_test standalone_test
For the self-test to work in your build, make sure that your jsunit_self_test target
points to the JsUnit test suite located in jsunit/tests/jsUnitTestSuite.html, as our
example build.xml does.
We wrap up this section by noting that more advanced test configurations are pos-
sible with JsUnit because it provides support for driving farms of JsUnit servers. A
JsUnit server is what allows tests to be performed from Ant; it acts under the covers of
our examples to drive web browsers on the local machine or on remote machines and
also creates the result logs.
JsUnit Firefox tip: permission denied
If you get a permission denied error in Firefox, set the security.fileuri.
strict_origin_policy to false .
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search