Variables and Dataset
Variables and Dataset allows you to create data with dynamic values and reuse them across actions, assertions and testcases. This makes your test cases more flexible and reusable and simplifies the process of updating values across multiple tests. The test cases can be executed with different data inputs, making your tests more robust and scalable.
Variables
Variables are used to store dynamic values that can be used across actions, assertions, and test cases. You can create variables to store values like URLs, usernames, passwords, and other dynamic data that you want to reuse across multiple test cases. Variables can be used to parameterize test cases, reuse test steps with different inputs, and simplify the process of updating values across multiple tests. They are the main master data that can be used across the test cases.
Key Fields of Variables
-
Name
- The name of the variable, required for easy identification. This field must be specified for all variables.
-
Data Type
- Specifies the data type of the variable, such as text, number, boolean, or date. The data type determines the format of the variable value.
The data type of a variable cannot be changed once it is created. If you need to change the data type, you must create a new variable with the desired data type.
-
Default Value
- Sets the default value for the variable. The value can be a static value or a dynamic value by mapping it to available utility functions.
-
Sensitive
- Determines whether the variable value is sensitive and should be masked in logs and reports. Enabling this option ensures that the variable value is not displayed in logs or reports or any other place where the variable is used. This is useful for storing sensitive information like passwords, API keys, or other confidential data.
Updating Variables
When you update the default value of the variable, there are options to select an action to take on the existing dataset values. You can choose to update the dataset values with the new default value or keep the existing dataset values. This option is useful when you want to update the default value of the variable and apply the changes to the existing dataset values.
Deleting Variables
You cannot delete a variable if it is being used in any action, assertion, or test case. You must remove the variable from all actions, assertions, and test cases before deleting it. Once you delete a variable, it cannot be recovered. Also the variable will be removed from all the datasets.
Dataset
Datasets are used to create a collection of data records that can be used to run test cases with different data inputs. When you create a dataset, you create a copy of the variable and override the default value with the dataset value whereever is required. You can use datasets to run test cases with different data inputs, making your tests more robust and scalable. Datasets are used to parameterize test cases, reuse test steps with different inputs, and simplify the process of updating values across multiple tests.
Updating Values in Dataset
When you update the value in the dataset, the value is updated only for that dataset record. The default value of the variable remains unchanged. This allows you to run test cases with different data inputs without affecting the default value of the variable.
Running Tests with Dataset
When you run a test case or a test suite, you have an option to select the dataset to be used for the test run. You can select the dataset from the available list of datasets and run the test case with the selected dataset. The test case will be executed with the data values from the selected dataset, allowing you to run the test case with different data inputs. If you select default dataset, the test case will be executed with the default values of the variables.
For more details check Run Testcase documentation.