Home Corporate Contacts TETware Java API Overview |
ProductsSolutionsInformationDatasheetDocumentationFAQKnowledgebase |
4. Processing Java test casesIntroductionThe subsections that follow describe how to use tcc to build, execute and clean Java test cases. The Scenario FileIn 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:
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 CaseA 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:
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:
Executing a Java Test CaseA 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:
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:
Cleaning a Java Test CaseFor 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:
|