Data Provider
What is a Data provider?
- Data Providers is a methodology set to pass data explicitly to the scripts.
- The data is stored in a data source like an excel sheet, property file, etc and then it is used as input for a script.
Why do we need a Data provider?
- Data providers are used to avoiding hard coding.
- Instead of having hard-coded input, you have new data each time the script loads the data from the data source.
- If the user uses a Data provider, there is no need to Re-Compile the Script for data modification.
- Using a Data provider, data can be modified easily without intervening in the code.
- Maintenance of test data will be easy if the Data provider is used.
Prerequisites for Data provider:
- A project should be created.
- A file should contain all the test data in it.
Navigation to the data provider settings screen:
Test development >> Module >> Script >> Settings tab >> Data provider
Columns present under Data provider:
- Name: This column displays the name of a data provider that the user will provide while adding the sheet from the “Create Data provider” popup. This popup is explained below. Do not allow “Duplicate names”. Also, when you click on the Data provider name it should open the “Details” popup which is explained below.
- Type: This column displays the type that is selected while adding the sheet from the “Create Data provider” popup as static text.
- File Name: It displays the name of the file that is selected in the “Create Data provider” popup as static text.
- Sheet Name: It displays the name of the sheet that is selected in the “Create Data provider” popup as static text.
- From Row: Here, it displays the selected row number from the “Create Data provider” pop-up as static text.
- To Row: Here, it displays the selected row number from the “Add Data provider” pop-up as static text.
- Actions: Under this column, three icons are present and the icons are displayed only when hovered by the mouse. The icons to be provided are detailed below:-
- Edit: Clicking on which, should open a popup and the label of the popup should be “Edit Data provider” the contents of this popup are explained below.
- Delete: There are two scenarios to delete a data provider which are explained below in detail.
- More Actions: It displays a context menu with two options:
- View Data: On clicking the “View Data” option, the “View Data provider- <Dataprovider name>” pop is displayed with details like “File name”, “Sheet name” and the “Data” present in that sheet.
- Details: On clicking the “Details” option, the details of the data provider are displayed in the popup which is explained below.
Data provider Details popup:
- The “Data provider Details- <Dataprovider name>” will be the header of the popup.
- Below the header, the “Name”, “Type”, “File name”, “Sheet name”, “From row”, “To Row”, “Created By”, “Created On”, “Modified by”, and “Modified on” details are displayed.
Creating Data provider:
- Click on the “+ Data provider” button.
- The “Create Data provider” popup will be prompted.
- Enter the name in the “Name” text field.
- Choose the Test data file from the “File name” dropdown.
- Choose the sheet name from the Test data file is selected, in the “Sheet name” dropdown.
- Initially, “From Row” and “To Row” will be auto-selected as “1” and “Till the last row” respectively.
- The user can vary the “From Row” and “To Row” by selecting from the dropdown.
- Select the “Data provider type” radio button, by default, “Excluding Pre – Post Condition” is selected.
- If you select the “Include pre-post condition” option under the “Data provider type” field, the Iteration type option is displayed.
- Initially, by default, the “Consider all iterations of Data provider as one Script” option is selected under the Iteration type.
- Click on the “Create” button.
The functionality of the Data Provider:
SCENARIO 1: When the user selects the “Excluding Pre and Post Condition” radio button.
- The user can add multiple excel sheets in the “Data Providers” table by clicking on the “+ Data provider” button.
- Users can access the “Data provider variable” for all the steps in the NLP parameter popup by using the “$” symbol only when they have configured the data provider.
- There are seven options for every step inside the “If fail checkpoint” i.e.
a. Mark this step as Failed and continue the current iteration.
b. Mark this step as Failed and stop the current iteration.
c. Mark this step as Failed and continue script execution.
d. Mark this step as a Warning and continue script execution.
e. Mark this step as Failed and stop script execution.
f. Mark this step as Failed and stop the current module execution.
g. Mark this step as Failed and stop the current Suite execution.
NOTE 1: For all the new steps which you add after configuring the data provider excluding pre and post conditions the default “If failed” checkpoint should be “Mark this step as Failed and continue current iteration”. But you can change it, if and when needed.
NOTE 2: If you have already written some steps and then configure the data provider excluding pre and post conditions then, already selected “If failed” checkpoints will not replace with the default checkpoint i.e. “Mark this step as Failed and continue the current iteration”.
- You can add start iteration and end iteration NLP’s anywhere in the script in between steps. When you call “Start Iteration” NLP, inside the NLP parameter popup, a dropdown will be present the label of the dropdown is “Data provider Name” and the placeholder for the dropdown will be “Search and select a data provider”. The options of this dropdown are all the data providers that you have configured in the “Data providers tab” (all the data providers present in the “Data providers” table). When you click on the “Add” button in the NLP parameter popup it displays the NLP as “Start iteration using <<Dataprovider Name> Data provider”. E.g. “Start iteration using Organization Data provider”.
- If you have configured the data provider and if you have not used the data provider variable in any of the steps then, you are allowed to run the script.
- The data provider variable is not displayed outside the start and end iteration NLP’s.
- You are not allowed to add “End iteration NLP” without adding “Start iteration NLP”.
How to configure the Data provider in the Script?
- To call a “Data provider” in the step, we should start with the “Start Iteration” NLP.
- Upon selecting the “Start Iteration” NLP from the NLP dropdown, the “NLP Input Parameter” div to add “Start Iteration” NLP is prompted, in which the “Data Provider Name” field is present, which contains all the data provider’s data which are added in “Settings” tab, as options in the dropdown.
- Select the appropriate data provider from the dropdown and click on the “Add” button, then the “Start Iteration” and “End Iteration” two steps get added.
- The user cannot explicitly add the “End iteration” step.
- After adding the “Start Iteration” NLP, we can start adding the other steps in-between “Start Iteration” and “End Iteration”.
- While creating a data provider, the option to “Create a variable” with the “Column name” as value is provided, we can use that variable as input for Steps, which are added in-between “Start Iteration” and “End Iteration” NLP’s.
Functionally of Icons of “Start Iteration” and “End Iteration”:
- When you select the checkbox beside “Start iteration”, all the checkboxes of steps will be selected.
- SL number will not be present for “Start iteration” and “End iteration”.
- If there are any steps present outside “Start iteration” and “End iteration”, the steps inside “Start iteration” and “End iteration” will have the continuation serial number of the outside steps.
- If we select only a few steps inside the “Start iteration” and “End iteration” frames, the checkbox beside “Start iteration” and “End iteration” will be partially selected.
- The drag and drop of steps can be performed within the “Start iteration” and “End iteration” frame only.
- We cannot drag the step present inside the “Start iteration” and “End iteration” frame and drop it outside the frame of “Start iteration” and “End iteration”.
- Users can drag the steps which are present outside “Start iteration” and “End iteration” and drop them inside the frame of “Start iteration” and “End iteration”.
- The “+”(Add step) icon will be present beside each step even for “Start iteration” and “End iteration”.
- For excluding pre/post condition cases: The “Run until” icon present under the “Actions” column, will be disabled from “Start iteration” till the last step present before “End iteration”.
- The “Run until” icon will be enabled only for “End iteration”.
- If there are no steps between “Start iteration” and “End iteration”, the “Run until” icon will be disabled for the “Last iteration” step as well.
- If there is a Nested “Start” and “End” iteration with no steps inside, the “Run until” icon will be disabled for the inside “Last iteration” step as it has no steps, whereas “Run until” will be enabled for the outside “End iteration” step.
The “Edit” and “Delete” under the “Actions” columns will be disabled. The “More” icon under “Actions” will be enabled always.
Edit a Data provider:
- Hover the mouse on a Data provider which you need to Edit.
- Click on an ‘Edit’ icon.
- A popup with the header ‘Edit Data provider -<<Dataprovider Name>>’ is prompted.
- You can make the changes required.
- Click on the “Update” button.
Delete a Data provider:
- Hover the mouse on a Data provider which you need to Delete.
- Click on the ‘Delete’ icon.
- A “Warning message” popup is prompted.
- Click on the ‘Delete’ button.