13Data Driven Testing
Data Driven Testing
This chapter describes data driven testing. It includes the following topics:
Overview of Data Driven Testing
Data driven testing is a test design and execution strategy. In the context of Siebel Test Automation, it is the ability to separate the data from test scripts and to manage it using data sets. It also extends ability to iterate the same test script through variations in data.
A data set in Siebel represents a two dimensional table with parameters as columns and values for these parameters as rows. You can import the data set into Siebel from flat files (tab separated text files)
Creating a Data Set
You can create any number of data sets and use them across test scripts. A data set can be created from the User Interface (UI), and it is recommended to import the data set from a flat file (tab separated text file).
To create a data set, do the following:
-
Navigate to Release, then the Data Set View
-
Click the plus ( +) icon from the Data Set Definition view to create a new record.
You can also add a new record using the Add Fields button.
-
Enter the value for the Name Field.
-
Click the plus ( +) icon in the Values Applet and enter the values.
-
Save the record.
Note: Copying a data set performs a deep copy of all fields and values as well.
Importing a Data Set
You can create or update a data set by importing flat files (tab separated text file). When imported, a new data set is created, the name of which is its file name. If the name already exists, you are prompted to overwrite with a new file name or not.
Prepare the data in spreadsheet and save it in a tab separated format. Ensure that the first column name is Sequence, and that it has the sequence numbers in the order you want.
To import a data set, do the following:
-
Navigate to Release, then the Data Set View A Data Set is created with same name as the file name and data is imported as Fields and Values into it.
If the name already exists, you are prompted to overwrite with a new file name or not.
-
Click the Import button and select the file to import.
A data set is created, the name of which is its file name. If the name already exists, you are prompted to overwrite with a new file name or not.
Exporting a Data Set
You can export a data set to a flat file.
To export a data set, do the following:
-
Navigate to Release, and then to the Data Set view.
-
Select the data set you want to export, and click Export.
-
Click Save.
Associating Test Scripts with a Data Set
You can associate a test script with only one data set.
To associate a test script with a data set, do the following:
-
Navigate to Release, and then to the Test Scripts view.
-
Select the required test script record, and then select the required data set.
-
Save the record.
Associating a Data Set with a Test Script
A data set can be associated with any number of test scripts.
To associate a data set with a test script, do the following:
-
Navigate to Release, then the Test Scripts view.
-
Select the required test script record, and then select the required data set.
-
Save the record.
Referencing Data Set Fields in Test Scripts
Apart from associating test scripts and data sets, data set fields also need to be referenced in test scripts. When you create a data set, you can name a data set using the Add Fields button as follows:
Applet name|Field name
When you do this, instead of using the input value, you can reference the data set as follows in the test script:
#
You need to ensure that the target object matches the Applet name|Field name naming format. It's recommended to use a meaningful short name when naming a Data Set column in the input, such as: #<name of column>
. For example, where Age is the name of the data field in a data set, you name it #Age
.
To reference a data set field in a test script
-
Navigate to the Release screen, then the Test Scripts view.
-
Select a record, and drill down on the record name.
-
Click a Test Step record.
-
Use the following examples to edit the Test Step record:
-
In Launch Test Step, if the associated data set has a User Name field with the value Employee, update this field to
#Employee
. -
In Input Value Test Step, if the associated data set has a Value/Variable field with the value Revenue, update this field to
#Revenue
.You can apply the same changes to the ItemRN and AppletRN fields.
-
Recommendations to consider when you reference a data set in a test script include the following:
-
The application performs no validation on referenced or unreferenced fields.
-
You can append the dollar sign ($) to your referenced field name to include a time stamp at run time. For example, the field
#Name$
appends a time stamp to values from the Name column in data sets.However, if a data set value already has a dollar sign appended to it, no timestamp is provided; and if the data set is balnk, then a field such as
#Name$
results in just the time stamp value. -
#@<variable name>
is supported to dynamically reference Data Set columns, which resolves to column name matching the value of the variable. For example,#@Var @Var
can contain Data Set field name. -
Data set field names cannot begin with
'@'
. -
From the data set, you can reference the User Id in Launch Action. For example,
#UserId
where User Id is a field name in the data set.
Iterations Types Available with Data Sets and Test Scripts
Test scripts can be either iterated over data set rows individually, or as a sequence of test scripts or test scenarios for each row of the Data Set. Use the following procedure to view the avalable iteration types.
To view the available iteration types
-
Navigate to the Release screen, then the Test Sets View.
-
Drill down on a Test Set record.
The three iteration options are as follows:
-
No iteration. If any iteration was selected previously, select the required records and click Remove Iteration. Only the first row from the data set is used for test scripts associated with the data set, and if the fields are referenced in the test scripts.
-
Individual Iteration. Select the required records and click Add Iteration. The field name Scenario Type reflects the individual iteration for the selected test scripts. The selected test script is run for all rows of the data set, followed by the next test script in the test set.
-
Scenario Iteration. Click Scenario Iteration, and then click OK when the confirmation prompt appears. The field name Scenario Type reflects the scenario iteration for all test scripts in the test set. A full test script sequence is executed for the first rows of the respective associated data sets, before picking up the next row of data sets. This applies to all test scripts in the test set.
-