Recording Scripts: Editing Your Script While Recording


While recording a script, you can pause to edit the script, inserting Java code or changing statements as necessary. Using the insert references option, you can select a component in your program under test and have JavaStar insert the reference automatically, speeding up your code additions and improving accuracy. When you're done, you can compile and save your changes, then continue on recording events as before.

The Script Editor that JavaStar opens in the Record/Playback window is not the same as the window you get when you click Edit Test Script in the JavaStar main menu. The Record/Playback editor includes a subset of the main Script Editor features. It also includes the Insert Reference feature, one specific to editing in record mode.

This section describes how to enter the script editor from record mode and how to use the Insert Reference feature. For information about the common features of both editors--Class Browser, Find/Replace, and Go to Line--see the chapter "Editing Tests."

Entering Edit Mode

  1. In the Record/Playback window, click the Edit button.
    JavaStar automatically pauses recording and opens a script editor inside the right panel of the window. See Figure 4-9. You can now edit the code, adding or changing lines, as you want.

    Script editor in the Record/Playback window

  2. When you complete your changes, click Save.
    You don't need to compile your script because JavaStar will compile and check the code itself when you stop recording.

  3. Click the Continue button in the left panel to resume recording.
    Now you can continue recording events as before, with your code changes incorporated into the script.

Inserting a Reference into a Script

With Insert Reference, you select a component and provide a variable name, and JavaStar then inserts a properly casted declaration, assigned to the variable name you specified. This is useful when you want to write your own verification code for more complex methods, such as methods that require parameters, or that return non-basic Java values.

To insert a declaration into a script you are recording:

  1. Click the Insert reference button.
    The Insert Reference dialog is displayed. See Figure 4-10.

    Insert Reference dialog

  2. In your program under test, click on the component you want to use.
    The declaration for the component appears in the lower text box of the Select for Declaration dialog.

  3. In the Name field, enter the name you want to use in your code to identify this component.
    Figure 4-11 shows a Select for Declarations dialog with a component selected and a name provided.

    Insert Reference dialog with fields filled in

  4. Click Apply to insert the object reference into your script.
    You can now, in subsequent code, refer to the component solely by the name you defined.



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