IBM Support

How to write a Java TSS Script

Troubleshooting


Problem

Basic guide to creating and using a Java TSS Script

Resolving The Problem

A Java test script must always extend com.rational.test.tss.TestScript. The "main" method of the script is located in a testMain(String args[]) method that executes on playback. Within the testMain, you have to start and end the services, starting them within a try catch block.

Here is a simple example, SimpleJavaTSS.java:

import com.rational.test.tss.*;

public class SimpleJavaTSS extends TestScript
{
public void testMain(String args[])
{
try {
tms.startTestServices();

// Scripting Code
System.out.println("Hello World");
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
tms.endTestServices();
}
}
}


You can only play a test script if you have defined where it is located. This can be done by:

1) Opening Tools -> Manage -> Test Script Types in Test Manager.

2) Select Java Script and press Edit.

3) Under the sources tab type a name like TSSJava and then type in the full path to your stored scripts under the Connect Info tab in the Data Path field. It is probably a good idea to make this path somewhere inside the datastore so they do not get lost or mixed with other projects.

4) Put the following values into Option Name and Option value:
Option Name Option Value
Type Java
Default datastore 0

5) Click OK.

When selecting a Test Script to be inserted into a suite or implemented by a test case, make sure to choose the Source that you defined above or else you will be unable to locate the scripts.

Compiling of the script will be done by Test Manager upon run time of the script.



[{"Product":{"code":"SSSHVH","label":"Rational TestManager"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Manual Test","Platform":[{"code":"PF033","label":"Windows"}],"Version":"2003","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21207154