com.artima.testkit
Class Runner

java.lang.Object
  |
  +--com.artima.testkit.Runner

public class Runner
extends java.lang.Object

Application that runs a suite of tests. The application accepts command line arguments that specify an optional runpath, zero to many Reporters, and zero to many Suite classes. Runner can be started in either of two ways. If testkit.jar is available on the classpath, then the command line takes the following form:

java [-cp <classpath>] com.artima.testkit.Runner [-p <runpath>] [reporter [...]] [-s <suiteclass> [...]]

If Runner is started using the executable jar file, the command line takes the following form:

java -jar testkit.jar -p <runpath> [reporter [...]] [-s <suiteclass> [...]]

Specifying a Runpath

A runpath is the list of filenames, directory paths, and/or URLs that testkit uses to load classes for the running test. If runpath is specified, testkit creates a java.net.URLClassLoader to load classes available on the runpath. The graphical user interface can optionally reload the test classes for each run by creating a new URLClassLoader for each run. If the testkit JAR file is available from the Java classpath, then the classes that comprise the test may also be made available on the classpath and no runpath need be specified.

The runpath is specified with the -p option. The -p must be followed by a space, a double quote ("), a whitespace-separated list of paths and URLs, and a double quote. For example:

-p "serviceuitest-1.1beta4.jar myjini http://myhost:9998/myfile.jar"

Specifying Reporters

Reporters can be specified on the command line in any of the following ways:

The [configs...] parameter, which is used to configure reporters, is described in the next section.

The -r option causes the specified specified in <reporterclass> to be instantiated. Each Reporter class specified with a -r option must be public, implement com.artima.testkit.Reporter, and have a public no-arg constructor. Reporter classes must be specified with fully qualified names. If the Testkit JAR file is available on the classpath, not run directly as an executable JAR file, the specified Reporter classes can also be deployed on the classpath. If a runpath is specified with the -p option, specified Reporter classes may also be loaded from the runpath. All specified Reporter classes will be loaded and instantiated via their no-arg constructor.

For example, to run a suite using two reporters, the graphical reporter and the print reporter writing to a file named "test.out", you would type:

-g -f test.out

The -g, -o, or -e options can appear at most once each in any single command line. Multiple appearances of -f and -r result in multiple reporters unless the specified <filename> or <reporterclass> is repeated. If any of -g, -o, -e, <filename> or <reporterclass> are repeated on the command line, the Runner will print an error message and not run the tests.

Runner adds the reporters specified on the command line to a dispatch reporter, which will dispatch each method invocation on itself to each contained reporter. Runner will pass the dispatch reporter to executed suites. As a result, every specified reporter will receive every report generated by the running suite of tests. If no reporters are specified, a graphical runner will be displayed that provides a graphical report of executed suites.

Configuring Reporters

Each reporter specification on the command line can include configuration parameters. Configuration parameters are specified immediately following the -g, -o, -e, -f, or -r. Valid configuration parameters are:

Each reporter has a default configuration. If no configuration is specified on the command line for a particular reporter, that reporter uses its default configuration. Runner will configure each reporter for which configuration parameters are specified via the reporter's setConfiguration method.

For example, to run a suite using two reporters, the graphical reporter (using its default configuration) and the print reporter configured to print only test failures, suite aborts, and run stops, and run aborts, you would type:

-g -eFBSA

Note that no whitespace is allowed between the reporter option and the initial configuration parameters. So "-e FBSA" will not work, and must be changed to "-eFBSA".

Specifying Suites

Suites are specified on the command line with a -s followed by the fully qualified name of a Suite subclass, as in:

-s com.artima.serviceuitest.ServiceUITestkit

Each specified Suite class must be public, a subclass of com.artima.testkit.Suite, and contain a public no-arg constructor. Suite classes must be specified with fully qualified names. If the Testkit JAR file is available on the classpath, not run directly as an executable JAR file, the specified Suite classes can be loaded from the classpath. If a runpath is specified with the -p option, specified Suite classes may also be loaded from the runpath. All specified Suite classes will be loaded and instantiated via their no-arg constructor.

The runner will invoke execute on each instantiated com.artima.testkit.Suite, passing in the dispatch reporter to each execute method.


Method Summary
static void main(java.lang.String[] args)
          App that runs a suite of tests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(java.lang.String[] args)
App that runs a suite of tests. For details, see the specification of this class.