7.0 Data Driving a Test
7.1 Parameterize tests
You can use the parameter feature in QuickTest to enhance your tests by parameterizing values in the test. A parameter is a variable that is assigned a value from various data sources or generators.
Two different groups of parameters
· Data Table parameters - parameter is taken from data table.
· Other parameter types - parameter values are taken from random number, external user-defined file or enviorment variables etc.
7.1.1 Parameterize test Manually
· You can parameterize a step recorded in your test or a checkpoint added to your test.
· You can parameterize steps and checkpoints manually by opening the appropriate dialog box.
· You can parameterize a step in your test tree while recording or editing your test.
When you parameterize a step, you can parameterize an object property, a method argument, or both.
7.1.2 DataTable Parameters
You can supply the list of possible values for a parameter by creating a Data Table parameter.
Data Table parameters enable you to create a data-driven test that runs several times using the data you supply. In each iteration, QuickTest substitutes the constant value with a different value from the Data Table.
7.1.3 Using Environment Variable Parameters
QuickTest can insert a value from the Environment variable list, which is a list of variables and corresponding values that can be accessed from your test. Throughout the test run, the value of an environment variable remains the same, regardless of the number of iterations,
There are three types of environment variables:
18.104.22.168 User-Defined Internal
User defined internal variables are the variables that you define within the test. They are saved with the test and accessible only within the test in which they were defined.
Steps to add or modify environment variable parameters:
· In the Edit value section of the Object Properties, Object Repository, Method Arguments, or Checkpoint Properties dialog box, click Other as the type of parameter you want to use.
· Click the Edit Parameter Options button next to the parameter type box. The Parameter Options dialog box opens.
· Select Environment in the Parameter Types box.
· Accept the default name or enter a new name to add a new user-definedinternal environment parameter, or select an existing environment variable name from the Name box. If you select an existing internal parameter, you can modify the value.
· If you created a new parameter or selected an existing user-defined-internal parameter, enter the value for the parameter in the Value box.
· Select the Regular Expression check box if needed and Enter the regular expression
· Click OK to save your changes and close the dialog box.
22.214.171.124 User-Defined External
User defined external variables are the variable that you pre-defined in the active external environment variables file. You can create as many files as you want and select an appropriate file for each test. Note that external environment variable values are designated as read-only within the test.
To define these variables create an external environment variables file
To select the active external environment-variables file:
· Choose Test > Settings to open the Test Settings dialog box.
· Click the Environment tab.
· Select the Load variables and values from external file (reloaded each test run) check box.
· Use the browse button or enter the full path of the external environment- variables file you want to use with your test.
Built-in variables, such as Test path and Operating system. They are accessible from all tests, and are designated as read-only.
7.2 Create data-driven tests
QuickTest Pro enables you to create and run tests, which are driven by data stored in table.
When you test your application, you may want to check how it performs the same operations with multiple sets of data. For example, suppose you want to check how your application responds to ten separate sets of data. You could record ten separate tests, each with its own set of data. Alternatively, you could create a data-driven test with a loop that runs ten times. In each of the ten iterations, the test is driven by a different set of data.
7.3 Local and Global Data Tables
Each action also has its own sheet in the Data Table so that you can insert data that applies only to that action. When there are parameters in the current action’s sheet, you can set QuickTest to run one or more iterations on that action before continuing with the current global iteration of the test.
The Global sheet contains the data that replaces parameters in each iteration of the test. When you run your test, QuickTest inserts or outputs a value from or to the current row of the global data sheet during each global iteration.
7.3.1 Using the Data Driver to Parameterize Your Test
The Data Driver enables you to quickly parameterize several (or all) objects, methods, and/or checkpoints containing the same constant value within a given action. Similar to a ‘Find and Replace All’ operation versus a step-by-step ‘Find and Replace’ process, you can choose to replace all occurrences of a selected constant value with a parameter. QuickTest can also show you each occurrence of the constant so that you can decide whether or not to parameterize the value.
To parameterize a value using the Data Driver:
· Display the action you want to parameterize.
· Choose Tools > Data Driver. The Data Driver scans the test for constants (this may take a few moments) and then the Data Driver opens.
The Data Driver displays the Constants list for the action. For each constant value, it displays the number of times the constant value appears in the action.
By default, the list displays only the following constants:
The argument value of each Set method
The argument value of each Select method
The value of the second argument (Value) of each SetTOProperty method
· If you want to parameterize a value that is not currently displayed in the list (such as an object property value), click Add Value. The Add Value dialog box opens.
Enter a constant value in the dialog box and click OK. The constant is added to the list.
· Select the type of parameterization you want to perform:
Step-by-step parameterization—Enables you to view the current values of each step containing the selected value. For each step, you can choose whether or not to parameterize the value and if so, which parameterization options you want to use.
Parameterize all—Enables you to parameterize all occurrences of the selected value throughout the action. You set your parameterization preferences one time and the same options are applied to all occurrences of the value.
If you selected Step-by-step parameterization, click Next. The Parameterize the Selected Step screen opens.
If you selected Parameterize all, the Parameter details area is enabled in the Data Driver main screen. Select your parameterization preferences the same way that you would for an individual step.
· In the Step to parameterize area, the first step with an object property, method argument, or checkpoint value containing the selected value is displayed in the test tree on the left. The parameterization options for the step are displayed on the right.
By default, the value is parameterized as a Data Table variable. Accept the default parameterization settings or set the parameterization options you want to apply to this step.
§ Click Next to parameterize the selected step and view the next step containing the selected value.
§ Click Skip if you do not want to parameterize the selected step.
§ Click Finish to apply the parameterization settings of the current step to all remaining steps containing the selected value.
· If you clicked Next in the previous step, and steps remain that contain the selected value, the Parameterize the Selected Step screen opens displaying the next relevant step. Repeat step previous for each relevant step.
If there are no remaining steps containing the selected value, the Finished screen opens.
· Click Finish. The Data Driver Wizard closes and the Data Driver main screen shows how many occurrences you selected to parameterize and how many remain as constants.