Data-driven testing lets you define parameters in your tests and use them in any step. You can define multiple ordered data sets and have the test run against each set separately using the Testim CLI.
When using data sets, previous data will not be automatically removed from test until explicitly removed.
- Run a signup test with different data - when you want to test your signup page with different user name and password, you can use Test Data and Conditions to build one test in Testim that will run several times with different usernames and passwords (negative or positive)
- Read\inject data from a database - when you want to inject data into a database and then pass the data that was generated by the test. To generate the data you can use Testim CLI hooks and after the injection of the data was successfully completed, you can pass the data to your test.
Test data can be added to a test in three ways:
- Through the Config file - the configuration file is a common JS containing all the required parameters to run your test suite and run hooks. Through one of these hooks it is possible to add test data to specified tests. This data set can override the dataset that was defined in the visual editor. See Configuring Data-driven Tests Using the Config File. The test can be run using the CLI, while adding a flag to use the config file in this run.
- Through an external file- Test data from external sources (e.g. CSV, DB etc.) can be passed to one or multiple tests using the Config file. The test can be run using the CLI, while adding a flag to use the config file in this run. See Configuring Data-driven Tests Using Data From an External Source
- Go to Suite runs view and go to the suite that you just run.
- You can see the run result with the Data Set per test when you hover the "i" icon in the right side of the test and then click the See Data Set button.
If you need cookies to be loaded before your system loads or you need cookies for a particular test, you can also define cookies using the reserved
cookies parameter. The cookies parameter can be added through the visual editor and through the Config file.
Read all about the setting cookies options here.
Updated 10 months ago