Once you have scripts edited to use parameters, you're ready to compose new JSTs or modify existing tests to pass parameters and define constant values. This section shows you how to modify the acceptance test to incorporate parameters to support the newly edited scripts.
Note - You don't have to create a JST to use parameters. If you have a script that runs start-to-finish without needing any other script, and you want to use parameters, you can go ahead and replace portions of the code with argument references. Then, when you run the script, you just need to specify each of the parameters in the Test arguments field of the Run test window. This works for small, contained test cases--for anything more complex or varied, composed tests are where you'll access the power.
Just as you examined the scripts to see where you want to add parameters, now you'll examine the acceptance test to see how you want to supply those parameters to the scripts.
An outline of Acceptance.jst
(something similar to the outline you seen in the Results Viewer when you expand all nodes) shows the nodes as:
An outline view of Acceptance.jst
The scripts that you edited to take parameters are underlined in this illustration. At the very least, you need to set up these nodes to pass parameters. But you can do more than that.
JavaStar supports three ways of supplying parameters to a node:
For the acceptance test to work properly, EnterFieldData
, DefineSearch
, GetSearchResults
and VerifyRecord
require identical data (though DefineSearch
and GetSearchResults
use only portions of the record). Because of this, it makes sense to set these parameters not at the level of particular test nodes, but at the level of the first common parent.
You can do this using parent parameters, by setting up an inheritance scheme so that the nodes for these scripts inherit the parameters from their parent node, and the parent nodes then inherit the parameters from their parent (Acceptance.jst
). You then supply the parameter values at runtime.
OpenFile
requires the filename for the test database. You can pass this as a constant or inherit it from the parent. For this example, you'll use a parent parameter.
Figure 6-3 shows the outline again, this time with all the nodes that pass parameters marked in bold. Based on this plan, all parent nodes will pass parameters down to child nodes. EnterFieldData will inherit parameters from AddRecord.jst
, and AddRecord.jst
will inherit these same parameters from the test arguments passed to Acceptance.jst
.
Acceptance.jst
with parameter nodes underlined.
How you define the parameter structure for Acceptance.jst
doesn't affect how you use these scripts with another JST. You might want to create a JST that populates a Name Database with records, and that might mean calling AddRecord.jst
repeatedly. In that case, you'd probably define each AddRecord node to pass the parameter values as constants, rather than define all of them as test arguments.
Note - Another way to populate a database using AddRecord would be to edit a script yourself to read data in from a property file, then use a combination of setProperty()
and getProperty()
to set field values. You'll learn more about adding custom code to scripts in the chapter "Using the JavaStar API."
Send feedback to
JavaStar-feedback@suntest.com
Copyright © 1998
Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, CA 94303.
All rights reserved.