Automated tests send requests to the tested web service and cover a certain area of this service. Rather often, they use only one set of parameters, that is, check one set of data. It is quite possible that this data does not cause errors in web service functioning, but other data may cause them. To get better coverage, you can run tests with different data. This will help you ensure that your API works as expected for various input values. This is what data-driven testing is about.
You can create several requests or test cases with different data. However, a better approach is to separate data from test steps. That is, instead of using hard-coded values, a data-driven test can read test data from some storage, like a CSV file or database, and use this data to parameterize requests it sends. This separation makes your test logically simpler. Also, it is easier to edit and maintain such tests in comparison with a test that contains several sets of hard-coded values.
It is considered to be a good practice to store both input data and verifying values in a data storage. This approach lets you easily specify verification data for each portion of test data.
In ReadyAPI, you can use various data sources:
For complete information, see Data Source Types.
You add the DataSource test step to your test case and connect it to a data source of the supported type (see above).
You then select the data source columns to be available in tests. In ReadyAPI terms, these columns are called properties.
To refer to a property, you use special expressions called property expansions, for example:
The test engine will “expand” this expression during the test run. For complete information on them and supported syntax, see Property Expansion.
You can type these expressions, or use the Get Data command to invoke a dialog, where you can choose the needed property visually (see below). You can find this command in the context menu. Some edit boxes and grid cells also offer the ellipsis button:
Here is a sample view of the dialog:
Property expansions are universal. You can use them not only to retrieve database data, but also to extract values from XML and JSON responses and pass them to other test steps.
For detailed step-by-step explanation, see Tutorials below.
Follow these links to learn how you can use various data sources for data-driven testing of your APIs: