Functional tests with external data
You can use external data to data-drive functional tests. When you data-drive a test, the script uses variables for key application input fields and programs instead of literal values so that you can use external data as you data-drive the application you are testing.
Data-driven testing uses data from an external file, a dataset, as input to a test. A dataset is a collection of related data records. When you data-drive test, datasets supply data values to the variables in a test scripts during test script playback.
Because data is separated from the test script, you can:
- Modify test data without affecting the test script
- Add new test cases by modifying the data, not the test script
- Share the test data with many test scripts
The diagram on the left shows a test script, which uses data with hard-coded, literal references in the test script. The diagram on the right shows a data-driven test script that uses data from an external file, a dataset.
Hard-coded test script with literal references Data-driven test script with a dataset
Here are some examples of problems that data-driving tests solves:
Problem: During recording, you create a personnel file for a new employee, using the employee's unique identification number. Each time the test is run without data-driving the test, there is an attempt to create the same personnel file and supply the same identification number. The application rejects the duplicate requests.
Solution: You can data-drive the test script to send different employee data, including identification numbers, to the server each time the test is run.
Problem: You delete a record during recording. When you run the test without data-driving the test, HCL OneTest™ UI attempts to delete the same record, and Record Not Found errors result.
Solution: You can data-drive the test script to reference a different record in the deletion request each time the script is played back.
Data-driving tests gives a more accurate picture of the way the application under test works in the real world with real data.