Parameterized tests
Summarize
Summary of Parameterized tests
Parameterized testing in the Automated Test Framework (ATF) allows you to execute a test multiple times with different sets of data. This feature enhances test efficiency by eliminating redundant test steps, promoting test reuse, and generating distinct results for each data set.
Show less
Key Features
- Parameters: These are unique variables that store specific test data. They can be shared across tests or exclusive to a single test, with shared parameters appearing as columns in the Test Run Data Sets table.
- Data Sets: Each data set contains runtime values for parameters. You can create these data sets manually or import them from a file. All data sets must be defined for the parameterized tests to execute successfully.
- Execution: ATF runs each parameterized test once for every data set, maintaining the same test steps and order of execution.
- Reporting: Test results are organized by the execution order of the data sets, with detailed records available for review.
Key Outcomes
By implementing parameterized tests, ServiceNow customers can streamline their testing processes, reduce redundancy, and improve the clarity of test results. This capability is particularly useful for testing scenarios that require variations in input data, such as validating the incident form with different categories and priorities.
Next Steps
- Create a parameterized test by defining parameters that hold your test data.
- Add parameterized data sets to specify the runtime values for parameters.
- Review test results to analyze performance and ensure test coverage.
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.