10 Launching a JTR Test
In this chapter we are going to see how to launch a JTR test you have written. You can choose between two different ways:
  1. you can use the jtr.test.Test class main method
  2. you can use a class of yours
 
Compulsory JVM system properties
Independently of your choice, you must remember that the two following system properties are required:
  1. jtr.test.Test.config: its value must be the path to the jtr.xml file describing the test-suite
  2. log4j.configuration: its value must be the path to the log4j.xml configuration file
 
Let’s now see how the two different scenarios work.
 
Using the jtr.test.Test class main method
In this scenario you leverage on the main method exposed by the jtr.test.Test class to launch your test-suite. The best way you can work with this class is writing an Ant target like the following one:
 
<target name="jtr" depends="init">
    <java classname="jtr.test.Test" dir="./" fork="true">
        <classpath refid="${runtime.classpath}" />
        <!-- JTR standard properties -->
        <jvmarg value="-Djtr.test.Test.config=config/jtr.xml"/>
        <jvmarg value="-Dlog4j.configuration=config/log4j.xml"/>
        <!-- Required JVM properties for distributed testing -->
        <jvmarg value="-Djtr.remote.test.host=localhost"/>
        <jvmarg value="-Djava.security.policy=java.policy"/>
        <!-- Optional JVM useful property -->
        <jvmarg value="-Dcom.sun.management.jmxremote"/>
    </java>
</target>
 
In the above snippet, as you can see, the main class is the jtr.test.Test class. Skipping the classpath setting we can concentrate on the set JVM arguments.
 
First of all we have the two properties introduced before, required for identifying the right jtr.xml file describing the JTR test-suite and for properly configuring the Log4J sub-system.
 
The other two properties are required if you intend to perform distributed testing sessions too. For a more detailed description of those properties, please go here.
 
Using your own classes
You can even a class you have written on your own for launching a JTR test-suite. Acting this way you simply have to instantiate an object of type jtr.test.Test and call its run() / start() method according to your needs.
 
Note: even in this case, please remember to set the JVM properties discussed so far.