Tutorial

Running tests

Section contents

General instructions

You can use any JUnit compatible test runner to run actiWATE tests. In order to do that, perform the following actions:

  1. Compile actiWATE tests. actiWATE JAR files should be added to the Java classpath. These files are placed in ACTIWATE_HOME\lib\ where ACTIWATE_HOME is the directory where actiWATE Framework is installed.
  2. Create the file actiwate.properties and specify configuration properties (see Configuration file).
    baseURL=http://www.actiwate.com/samples/
    filelogging.enabled=yes
    filelogging.directory=logs\
    filelogging.level=debug
    
  3. Run tests using any JUnit compatible test runner. File actiwate.properties should be either in the current directory or in the Java classpath. The Java classpath should contain all JAR files from directory ACTIWATE_HOME\lib\.

More specific instructions for certain JUnit compatible test runners are presented in sections Standard JUnit test runner, Jakarta Ant build tool, IntelliJ IDEA IDE, and Eclipse IDE.

Tests execution from other tools was not tested. But since actiWATE tests are compatible with JUnit, you can use various tools to run actiWATE tests. Instructions on how to run JUnit tests from different IDEs can be found at http://www.junit.org/news/ide/index.htm.

Standard JUnit test runner

The following scenario illustrates how to run actiWATE tests using standard JUnit test runner under Windows operating system. With minor changes it can be applied to other operating systems.

  1. Compile tests. actiWATE JAR files should be added to the Java classpath. These files are placed in ACTIWATE_HOME\lib\ where ACTIWATE_HOME is the directory where actiWATE Framework is installed.
  2. Set the environment variable ACTIWATE_LIB to ACTIWATE_HOME\lib\.
  3. Construct the environment variable ACTIWATE_JARS so that it includes all actiWATE JAR files.
    set ACTIWATE_JARS=%ACTIWATE_LIB%\actiwate.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\junit.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\commons-logging.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\HttpClient.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\jaxen-full.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\js.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\log4j-1.2.8.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\nekohtml.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\resolver.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\saxpath.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\xercesImpl.jar
    set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\xml-apis.jar
    
  4. Ensure that the environment variable JAVA_HOME points to the directory with Java version 1.4.
  5. Create the configuration file actiwate.properties in the directory where you will run tests (see Configuration file).
  6. Run tests. Use the following command after replacing <Classes Directory> with the directory containing compiled tests classes and <Test Case> with the name of the test class.
    %JAVA_HOME%\bin\java.exe -classpath %ACTIWATE_JARS%;<Classes Directory>
    junit.textui.TestRunner <Test Case>
    

For additional information see JUnit documentation and actiWATE samples.

Apache Ant build tool

Add the following instructions to the Ant build file. We assume that Ant properties src.dir and classes.dir point to the directories with source code and compiled classes respectively, and names of actiWATE test classes end with suffix Test.

  1. Define a property pointing to the directory where actiWATE Framework is installed.
    <property name="actiwate.dir" location="<actiWATE Framework Directory>"/>
    
  2. Add actiWATE JAR files to the Java classpath to be used for tests compilation and execution.
    <path id="classpath">
        <fileset dir="${actiwate.dir}\lib\">
            <include name="*.jar"/>
        </fileset>
        <pathelement location="${classes.dir}"/>
    </path>
    
  3. Add Ant target, which will compile actiWATE tests.
    <target name="compile">
        <mkdir dir="${classes.dir}"/>
        <javac srcdir="${src.dir}" classpathref="classpath"
               destdir="${classes.dir}" verbose="no" debug="true">
        </javac>
    </target>
    
  4. Add Ant target, which will run actiWATE tests.
    <target name="run" depends="compile">
        <junit fork="yes" haltonfailure="yes" dir="${basedir}">
            <classpath refid="classpath"/>
            <formatter type="brief" usefile="false"/>
            <batchtest fork="yes" haltonerror="false" haltonfailure="false" >
                <fileset dir="${src.dir}">
                    <include name="**/*Test.java" />
                </fileset>
            </batchtest>
        </junit>
    </target>
    

So that you can run actiWATE tests you need to ensure that Ant uses Java 1.4 and file actiwate.properties is in the Ant base directory (see also Configuration file).

For additional information see Apache Ant documentation and actiWATE samples.

IntelliJ IDEA IDE

The following scenario illustrates how to run actiWATE tests within IntelliJ IDEA IDE.

  1. Create a new project or open an existing one.
  2. Ensure that Java 1.4 is used for the project. The procedure depends on the IntelliJ IDEA version. For version 4.x perform the following:
    1. Choose the menu item File > Settings;
    2. Select Paths page;
    3. Select Libraries (Classpath) tab;
    4. Add JDK 1.4 to the list of available JDKs if it not yet in the list, and select it as the target JDK.
    For version 3.x perform the following:
    1. Choose the menu item File > Project Properties;
    2. Select Paths page;
    3. Add JDK 1.4 to the list of available JDKs if it not yet in the list, and select it as the target JDK.
  3. Add actiWATE JAR files to the Java classpath. actiWATE JAR files are located in ACTIWATE_HOME\lib where ACTIWATE_HOME is the directory where actiWATE Framework is installed.
    1. On Paths page opened on the previous step choose Libraries (Classpath) tab for version 4.x and Classpath tab for 3.x;
    2. Use the button Add JAR/Directory for version 4.x and the button Add for 3.x to add actiWATE JAR files.
  4. Create configuration file actiwate.properties and specify configuration properties (see Configuration file).
  5. Use the directory containing actiwate.properties as a working directory for JUnit tests or add that directory to the Java classpath. To set working directory for JUnit tests perform the following actions:
    1. Choose the menu item Run > Edit Configurations;
    2. Select JUnit tab;
    3. Press the button Edit Defaults;
    4. Type the name of the directory in Working directory field.
    To add the directory in Java classpath perform the following actions:
    1. Open Paths page as described on step 2;
    2. Choose the tab Libraries (Classpath) for version 4.x or the tab Classpath for 3.x;
    3. Use the button Add JAR/Directory for version 4.x and button Add for 3.x to add the directory.
  6. Open the test class.
  7. Run the test either using the menu item Run > Run or using the menu item Run of the context menu.

For additional information see IntelliJ IDEA documentation.

Eclipse IDE

The following actions illustrate how to run actiWATE tests within Eclipse IDE:

  1. Create a new Java project or open an existing one.
  2. Ensure that Java 1.4 is included in the list of installed JREs.
    1. Select the menu item Window > Preferences;
    2. Select Java > Installed JREs in the tree pane to display Installed Java Runtime Environments preference page;
    3. Add Java 1.4 if it is not included in the list of installed JREs.
  3. Add actiWATE JAR files to Java build path. actiWATE JAR files are located in ACTIWATE_HOME\lib where ACTIWATE_HOME is the directory where actiWATE Framework is installed.
    1. Select the menu item Project > Properties;
    2. Select Java Build Path in the tree pane to display corresponding preferences page;
    3. Select Libraries tab;
    4. Use the button Add JARs or Add External JARs to add JAR files.
  4. Create the configuration file actiwate.properties in the root directory of the project and specify configuration properties (see Configuration file). If you want to place the file in another directory then you'll need to add the directory to the Java build path. You can do it in the same way as in the previous step, but using the button Add Class Folder.
  5. Choose the test class to run. Either open it by the editor or select in the navigator window.
  6. Run the test using the menu item Run > Run As > JUnit Test.
For additional information see Eclipse documentation.