Parameterized tests
Summarize
Summary of Parameterized Tests
Parameterized testing allows you to run a test multiple times with different data sets for each execution. This method enhances test efficiency by eliminating redundancy, enabling test reuse, and generating distinct results for each data set. The Automated Test Framework (ATF) substitutes parameters with respective data values during execution, facilitating varied test scenarios.
Show less
Key Features
- Parameters: Variables that store specific test data, each with a unique label and type, defined during test design. Parameters can be shared across tests or exclusive to a single test.
- Data Sets: Collections of runtime data used during test execution. You can create these manually or import from files. Each data set specifies parameter values and is crucial for successful test runs.
- Execution Model: Each parameterized test runs once per data set, maintaining the same test steps and order, producing results for each data set used.
Key Outcomes
By implementing parameterized tests, ServiceNow customers can expect improved testing efficiency, reduced duplication of effort, and clearer results to analyze. The ability to utilize shared and exclusive parameters, along with the flexibility of data sets, allows for comprehensive testing scenarios tailored to varied conditions. Customers should ensure data sets are defined to prevent test failures and leverage the structured reporting of results for better insights into test performance.
Run a test multiple times with different test data for each run. Create parameters to store test data for each test run.
Parameterized testing offers test designers these benefits.
- Eliminates the need to duplicate test steps just to change test data.
- Increases test reuse by separating test actions from test data.
- Produces a separate test result for each data set.
When the test runs, Automated Test Framework replaces the parameters with data set values. For example, you can create a test of the incident form that uses parameter values for the subcategory and priority fields. You can use one data set to test that the Antivirus category produces a high priority incident, and another data set to test that the Email category produces a low priority incident.
Parameterized test components
Parameterized tests consist of these components.
- Parameter
A parameter is a variable that stores a particular type of test data. Each parameter has a unique label and a data type. For example, you can create a parameter to store the Sys ID of a reference field or the integer value of a choice field. Define parameters during test design.
Parameters can be shared or exclusive. Shared parameters can be used in any parameterized test. Exclusive parameters can only be used with the test for which they were created. Each shared parameter is a column in the Test Run Data Sets [sys_atf_parameter_set] table. Each exclusive parameter is a record in the Parameter Variables [sys_atf_parameter_variable] table.
- Data set
A data set, also known as a test run data set, includes runtime data used when the test runs. You can set a value for every parameter available to the current test. Data sets specify the parameter value during test runs. You can manually create data sets for a test, or import data from a file. Each data set is a record in the Test Run Data Sets [sys_atf_parameter_set] table.
Parameterized tests fail if data sets are not defined.
Design Considerations
Follow these design considerations when creating parameterized tests.
- Parameterized tests support standard Automated Test Framework features, such as reports, test suites, and data rollback. Copying a parameterized test copies all parameters, test run data sets, and test steps.
- If you create a parameterized test that includes Custom UI test steps, the system only uses the first data set to retrieve components.
Parameterized test runs
Automated Test Framework runs each parameterized test once per data set, using the same test steps and execution order. For example, if a parameterized test has five data sets, Automated Test Framework runs the test five times, once for each data set.
Parameterized test results
Parameterized tests display test results by the execution order of the data sets. Open each test result record to view the test details.
The Parameterized Test Result record Description field lists the parameters and data sets used in the test run.