Home Corporate Contacts

TETware Java API Overview


Products
Solutions

Information

Datasheet
Documentation
FAQ
Knowledgebase

4. Processing Java test cases


Introduction

The subsections that follow describe how to use tcc to build, execute and clean Java test cases.


The Scenario File

In the scenario file the name of a Java test case should be specified without the .class suffix. For example, consider a test case whose source directory is ts/MyTestCase (relative to the test suite root directory). If the name of the source file for the test case is MyTestCase.java, the Java compiler leaves the compiled code in MyTestCase.class. This test case should be specified in the scenario file as follows:


      all
                  /ts/MyTestCase/MyTestCase

When a Java test case is specified in this way, tcc is able to use the tools described in the following subsections to process it in each mode of operation.


Building a Java Test Case


A build tool is included in the TETware distribution for use when building Java test cases. The name of this tool is jet-build and it is located in tet-root/bin. (On Win32 systems this tool is named jet-build.exe.) jet-build is provided as a convenience to test suite developers. You can use other mechanisms to build a Java test case if you want to. Indeed, if the test suite uses an alternate execution directory or any test case consists of more than one source file, it is likely that a more complex build tool will be required, such as make together with suitable makefiles. It may sometimes be appropriate to invoke jet-build from a makefile rule in these cases. jet-build takes the name of the test case source file as argument, without the .java suffix. It then adds a .java suffix to the test case name and invokes the Java compiler javac. Normally, jet-build searches for javac in the directories specified by the PATH environment variable in the usual way. However, this can be changed by using a build mode configuration variable called TET_JAVAC_PATH. For example, if javac is in /usr/local/java/bin, the following assignment in the build mode configuration file will enable jet-build to find the Java compiler even if that location is not in the search path:


      TET_JAVAC_PATH=/usr/local/java/bin/javac

This feature is particularly useful when building a Java test case on a remote system where the value of PATH inherited from tccd does not normally include the location of the Java compiler. The simplest way to use jet-build is when all the test cases in the test suite are Java test cases, and each test case consists of a single source file. Simply specify jet-build as the build tool in the build mode configuration. For example:


      TET_EXPAND_CONF_VARS=true
      TET_OUTPUT_CAPTURE=true
      TET_BUILD_TOOL=${TET_ROOT}/bin/jet-build

Executing a Java Test Case

A Java test case must be executed by the Java interpreter. In addition, certain environment variables must be set up to enable the Java interpreter to locate the Java API components. An exec tool is included in the TETware distribution which performs these functions. It provides the interface between tcc and the Java interpreter when executing Java test cases. The name of this tool is jet-exec and it is located in tet-root/bin. (On Win32 systems this tool is named jet-exec.exe.) jet-exec takes the name of the test case class file as argument, without the .class suffix. It sets certain environment variables to enable the Java runtime to locate the TCM and the API library, then invokes the Java interpreter java. Normally, jet-exec searches for java in the directories specified by the PATH environment variable in the usual way. However, this can be changed by using an execute mode configuration variable called TET_JAVA_PATH.


For example, if java is in /usr/local/java/bin, the following assignment in the execute mode configuration file will enable jet-exec to find the Java interpreter even if that location is not in the search path:


     TET_JAVA_PATH=/usr/local/java/bin/java

This feature is particularly useful when executing a Java test case on a remote system where the value of PATH inherited from tccd does not normally include the location of the Java interpreter. jet-exec can be used in several ways as follows:

  1. When all the test cases in the test suite use the Java API. Simply specify jet-exec as the exec tool in the execute mode configuration. For example:
    
              TET_EXPAND_CONF_VARS=true
              TET_EXEC_TOOL=${TET_ROOT}/bin/jet-exec
    
  2. When the test suite contains test cases that use several APIs. You will need to provide an exec tool that can distinguish between Java test cases and the others, and only use jet-exec to execute the Java test cases. One way to do this would be to group all the Java test cases below a common subdirectory. For example, the following shell script exec tool might be used to do this when all the Java test cases are below ts/JavaTests:
    
              # determine the test case name
              testcase=${1:?}
              shift
              # execute test cases below the JavaTests directory using
              # the Java exec tool;
              # execute other test cases directly
              case "$testcase" in
              */JavaTests/*)
                         ${TET_ROOT:?}/bin/jet-exec $testcase ${1:+"$@"}
                         ;;
              *)
                         ./$testcase ${1:+"$@"}
                         ;;
              esac
    

Cleaning a Java Test Case

For completeness, a clean tool is provided in the TETware distribution for use when cleaning Java test cases. The name of this tool is jet-clean and it is located in tet-root/bin. (On Win32 systems this tool is named jet-clean.exe.) Generally speaking, when it is appropriate to use jet-build as the build tool, jet-clean may be used as the clean tool. jet-clean takes the name of the test case class file as argument, without the .class suffix. It then adds a .class suffix to the file name and removes the class file. The simplest way to use jet-clean is when all the test cases in the test suite are Java test cases, and each test case consists of a single class file. Simply specify jet-clean as the clean tool in the clean mode configuration. For example:


      TET_EXPAND_CONF_VARS=true
      TET_OUTPUT_CAPTURE=true
      TET_CLEAN_TOOL=${TET_ROOT}/bin/jet-clean

Return to Contents



Home Contacts Legal Copyright Corporate News

Copyright © The Open Group 1995-2012, All Rights Reserved