Define API test properties or user/system variables

Relevant for: API testing only

Define test parameters

This step applies if you want to define custom parameters that can be used by all steps in the test, with the ability to assign data from a data source.

  1. Click the Start or End of the test flow. In the Properties pane, open the Test Input Parameters view .

  2. Click the Add button to define a new input or output parameter.

  3. In the Edit Input/Output Property/Parameter Dialog Box (API Testing), specify a parameter name and data type. All types that were defined in any reference file, are available.

  4. Click in the Default Value column and specify a value.

Back to top

Define user variables

You can create user variables and set their values. You can define multiple profiles for the variable values. You select a profile to be active before the test run.

  1. Click the Start or End of the test flow. In the Properties pane, open the Test Variables tab .

  2. Click the Add User Variable button  to define a new user variable.

  3. Give the variable a description and a default value.

Back to top

Set user variable values

You can set values for variables in one of the following ways:

  • In the Properties pane's Test Variables view, click in the Profile column and manually enter values.

  • Open the Toolbox pane and drag the Set Test Variable activity from the Miscellaneous category into the Test Flow (or loop). In the Properties pane, define the variable key and value. To obtain values, click the Link to a Data Source button in the row. In the Select Link Source Dialog Box (API Testing), select the Test Variables option. Select a name and value for the Variable key and Variable value.

  • Open the Properties pane's Events view for the step or define a Custom Code activity. Edit the event handler code and assign a value using the TestProfile object. The following example sets the value of the Region user variable to NE.

    activity.Context.TestProfile.SetVariableValue("Region", "NE"); 

Repeat this step for each variable for which you want to set values.

Back to top

Define user variable profiles

This step applies only if you created user variables as described in the above steps.

  1. Define one or more user variables as described above.

  2. Click the Add New Profile button .

  3. In the New Test Profile Dialog Box, specify a name and indicate the profile (if any) from which to copy the properties. If you do not copy the properties from an existing profile, UFT One copies the user variables from the active profile without its values.

  4. To rename or delete a profile, click the Manage Profiles button . In the Manage Profiles dialog box, click Remove or Rename.

  5. Click the Compare button to display the profiles side-by-side.

  6. Only the active profile is accessed during the test run. To make a profile active, select it from the Active Profile list.

Back to top

Set OS variable values for the test - optional

This step lets you set global operating system variables that will apply to all steps in the current test run.

  1. From the Toolbox pane and drag the Set OS Environment Variable activity from the System category into the Test Flow or another custom loop.

  2. In the Properties pane's Input/Checkpoints tab, define the variable key and value or click the Link to Source button  to specify a data source.

  3. Tip: To view a list of the test variables, click the Start or End of the test flow. In the Properties pane, open the Test Variables tab . The System variables are listed in the lower pane.

Back to top