Data-Driven Testing: How to Design Data-Driven Tests to Increase Their Scope
When automated tests are well-organized and written with the necessary detail, they can be very efficient and maintainable. But designing automated tests that deal with data can be challenging if you have a lot of data combinations. For example, let’s say we want to simulate a series of 20 customers, along with the number of products they buy, their locations, etc. From the point of view of test design, it is cumbersome to create 20 test cases that have the same workflow for different 20 customers. TestArchitect offers some alternatives to meet these needs.
First, create a “data set,” a worksheet-like data set file with rows of data values that will be provided sequentially to the test procedure. The data set can be predefined or be populated during the running of the tests, with external sources such as files or database query results.
Based on the data set, the test will contain variables that correspond to the columns in the data set and whose values are assigned during test execution from the rows in the data set. Here is an example where a test line with “create customer” is repeated for each row in the data set.
The data set functionality in TestArchitect also supports “filters.” The filters allow you the ability to only apply to the test those rows in the data set that meet certain criteria.
In the example above, we filter for customers who buy more than 15 units and who are from the states CA or NY only. As a result, the second and third data rows will be eliminated, while the first and fourth data rows meet both criteria and will be used in the execution.
Using data sets in TestArchitect can help you leverage your tests to multiple sets of data values. This will increase their scopes with minimal effort.