Composing Tests: Composing a JST


When you compose a JST, you create nodes that correspond to test scripts or other JST files. Then you specify the dependencies between these nodes by setting normal and exception conditions. You can set any node to restart the application or applet under test before the JST executes the node. You can change the root (starting node) from the default. You can also specify parameters to send to a node, assuming the script it represents accepts parameters.

The basic rules about JSTs are:

Most of the Test Composer functions are represented by buttons on the left side of the window (see Figure 7-3).

Compose test main buttons

You can also access these functions by putting your mouse cursor in the large open test area, holding down the right-mouse button, and selecting functions from the pop-up menu that appears. If you right click over an existing node or a connecting line, the menu displays only the options that apply to the node or connecting line.

This section describes:

Creating a Node

  1. Click the Add Test button or right-click in a blank area of the composer canvas.
    The Test Name box appears, prompting you for the test you want this node to represent.

    Test Name dialog

  2. Type the name of the script or JST you want to use, or click Browse to locate the file through the file dialog box.
    JavaStar shows script nodes as rectangles with squared corners and JST nodes as rectangles with rounded corners. If the name you enter ends with .jst, JavaStar inserts a JST node into your test. If you enter a name without a .jst extension, JavaStar inserts a script node.
    A script does not have to exist for you to define it as a node. You can define nodes that represent scripts you plan to record or write at a later date. A JST, however, must exist for you to reference it as a test name.

  3. Click OK.
    The node appears as a box with the script or JST title inside. If this is the first node you created for this test, it appears in blue to indicate that it is the root node.

Running the Test

The Run Test button is a short-cut to the Run Test command on the main menu. When you click this button, the Run Test dialog window appears, with your JST name already filled into the Test Name field.

You can now run the test as usual. Because you're running a JST, the JST Runner window appears with the Record/Playback window and your program under test. The JST Runner shows how JavaStar is progressing through the nodes (including nested JSTs) by flashing the currently executing node. If the test ends prematurely, you can see which node contains the problem, and edit it in the Test Composer or Script Editor, depending on the nature of the problem.

For information on how to use the Run Test window, see the chapter "Running Tests."

Duplicating a Node

Duplicating nodes is often useful, especially when you are creating a test that calls one script multiple times, changing only the parameters it sends with each call. All you have to do is duplicate and then edit the node.

  1. Click on the node you want to duplicate.
    The node darkens to confirm your selection.

  2. Click Duplicate.
    The node is duplicated, without links.

Deleting a Node

  1. Click on the node you want to delete.
    The node darkens to confirm your selection.

  2. Click Delete.
    The node is removed, along with any connection lines extending to or from the node.

    Note - You cannot delete a root node. If you want to delete a node currently set to root, first define another node as the root node (see Choosing a Root Node) then delete the original node.

Setting a Node to Restart

Restart nodes specify that when the JavaStar reaches this node during playback, the application under test will be restarted before executing the script (or JST) referred to by the node.

While you may have many reasons to restart a node during normal test functioning, the most common use is to handle exception conditions. By restarting the application, you return the test program to a predictable state, from which you can resume testing. Populating JSTs with exception conditions that link to restart nodes makes it easier to create long tests that run unattended--perhaps overnight--with reasonable assurance that the tests will complete, even with failures.

To set a node to restart:

  1. Click on the node you want to turn into a restart node.
    The node darkens to confirm your selection.

  2. Click Toggle Restarter.
    A red box appears around the node to signify that it is now a restart node.

To remove the restart condition from a node, you repeat the same procedure:

  1. Click on the node you want to return to a non-restart status.
    The node darkens to confirm your selection.

  2. Click Toggle Restarter.
    The red box around the node is removed, indicating that it is no longer a restart node.

Choosing a Root Node

A root node is the starting node for the test. You must have a root node for your test, and you can only define one node as the root. By default, the first node you create for a test is a root node. If you want to change the root node:

  1. Click on the node you want to turn into the root node.
    The node darkens to confirm your selection.

  2. Click Set root.
    A blue box appears around the node, indicating it is the root node.

Starting Normal and Exception Conditions

You link nodes together using normal and exception connecting lines, represented by green (normal) and red (exception) arrows.

A normal connecting line between two nodes means that the second node will only be executed if the first node ends normally. A normal condition means that the previous test did not throw an exception. This does not mean that all comparisons passed, because while a synchronization failure throws a specific exception, verification failures do not throw exceptions (though details are included in the test run log file).

An exception connecting line means the second node will only be executed if the first node ends with an exception. An exception condition means the script was terminated prematurely when an operation threw an exception. Exception connectors are particularly useful for introducing error recover into your tests--in combination with Setting a Node to Restart, your tests become quite powerful.

You can only have one normal and one exception condition starting at each node. There is no limit, however, on the number of lines of one type that connect to a single node.

To create a condition line:

  1. Click the node from which you want the condition to originate.
    When the test executes, JavaStar will evaluate the exit state of this node before proceeding to the next.

  2. Click either the Start normal or Start except button.
    Note that your selected node starts to flash. That's to confirm which node you chose and to let you know you have an operation in progress.

  3. Click on the node you want to execute next.
    An arrow appears extending from your start node to your end node.

Deleting a Connection

  1. Click on a connector line to select it.
    The line flashes to confirm your selection.

  2. Click the Delete button.
    JavaStar deletes the line.

Moving Nodes

Adding Comments

Use the comments field to explain the purpose of this JST and any important information other test developers might need to know when maintaining this test.

Editing a Node to Accept Arguments

In the Compose Test window, you can select any node and specify arguments you want to pass to it at execution time. JavaStar supports three types of arguments (also called parameters):

This section describes the basics of how to specify parameters for a node within a JST. For a detailed description of how to use parameters to make your tests more flexible or how to edit scripts to support parameters, see the
JavaStar Tutorial.

To edit a node:

  1. Click on an existing node.
    The node darkens to confirm your selection.

  2. Click on the Edit... button.
    The Edit node dialog appears with the test name filled in.

    Edit Node dialog

  3. Select the type of parameter you want to pass to this node.
    The pull-down menu to the right of the Value or Argument# field (set to Constant by default) provides three options. The label for the field to the left of the parameter type pull-down changes based on your choice--by default, the field label is Value.

    Parameter passing options

    Parameter Type Description
    Parent parameter Get this parameter from the parent node. If this node is part of a JST that does not have a parent, the parameter must be passed as a test argument at the time you run the test. Selecting this option changes the field name to the left to Argument#.
    Constant Pass the value as a constant. You specify the value for the constant in this window--note that the field to the left is labeled Value when you select this option.
    Property name Obtain this value from a Java property file. The field label to the left changes to Property Name when you select this type.

  4. Specify the value, argument #, or property name.
    The field to the left of the pop-up menu prompts you for the type of information you need to provide for the selected parameter type.
    If you want to provide a constant, enter the value. For example, if you're providing a numeric value that your script references, type the number directly into the Value field.
    For parent parameters, refer to the parameter you want to use by argument number. Remember that argument numbers start at 0, not 1. For example, if three parameters are passed to the parent node, and you want to use the second parameter in this script, enter 1 as the argument number.

    Note - For property files, you need to specify the name of the property file in JavaStar Playback Options. You can only have one property file defined at one time.


See Figure 7-6 for an example of an edited node.

A commented node that defines five parent parameters.

  1. Click Add (after) to make this parameter the next in the list.
    The parameter appears in the list box below.

  2. Continue adding parameters by repeating steps 3 and 4.

  3. Add text to the Comments field to describe the parameters you are passing.
    The comment field applies to the node itself, not a specific parameter. Adding a description here is particularly useful when you're passing parent parameters or using property names--you can save time you might spend later trying to decipher what you were trying to pass.

  4. Click Apply to put the changes into effect.

  5. Click Close to close the window.
    Note that now when you select this node, the parameters display in the Parameter Values text box, located at the bottom of the Test Composer window.

Editing Existing Parameters for a Node

With the edit node window open, you can delete a parameter, change the value, insert a parameter into the list.

To Delete a Parameter

  1. Select the parameter from the Parameters list.

  2. Click the Delete button.

  3. Click Apply to save the changes.

  4. Close the window.

To Change the Value of a Constant

  1. Select the constant from the list.

  2. Edit the value in the Value field.

  3. Click the Update button.

  4. Click Apply to save the changes.

  5. Close the window.

To Insert a Parameter Between Two Others

  1. Click on the parameter you want to proceed the new one.

  2. Enter the new parameter into the Value field.

  3. Click the Add (after) button.

  4. Click Apply to save the changes.

  5. Close the window.



Send feedback to JavaStar-feedback@suntest.com
Copyright © 1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, CA 94303. All rights reserved.