You can use CSV files or Test Data from Data Entities to drive API Monitoring tests. This is useful for testing various input combinations using a single test to increase the test coverage of your API.
In this article:
Prepare Your CSV Data File
BlazeMeter supports data files with the extensions .csv, .txt, or .dat, with a file size of no more than 5 MB.
Set your variables
Use the header row to define your variable names in a list of comma-separated strings. No other separator is supported.
id,name,country
This example has 3 data columns.
Data file example
The following is an example of a header row containing variable names and corresponding data values in the rows below. Each column corresponds to one variable and its values.
id,name,country
1,John,US
2,Jack,GB
3,Mike,IN
Use CSV Data Files in API Monitoring Tests
To upload and use your CSV data file:
Go to the BlazeMeter API Monitoring tab.
Open or create an API Monitoring Test.
Go to Editor > Environment > Test Settings and select Test Data.
Under Test Data Source, select Add CSV File.
Select Choose File, add your data file, then click Upload CSV File.
Define your Run Options. You can choose to use all the data rows in the file, or set a defined number of data rows from your file.
Restriction: Depending on your subscription plan, you may be subject to a limited number of data rows. If your specified Number of Rows exceeds the data row limit, the Test Data size will be automatically reduced to match your subscription.
(Optional) Choose whether to Run Data Iterations Sequentially. By default, data-driven API tests are running data iterations in parallel, which is faster.
Verify that the expected Test Data variables are now visible in the Editor under Steps.
You can now add data parameters using the test data variables in your Request and Assertions sections, much like regular variables. For more information, see Use Variables to Pass Data Between Steps (Chained Requests).
Prepare Your Data Entities
To add a Data Entity:
Go to the BlazeMeter Performance or Functional tab.
Navigate to Test Data.
Select Add Data Entity.
Choose from Create New Data Entity, Import Data Entity from exported file, or Create New Data Entity from exported file.
For more information on creating and modifying Data Entities, see Available Data Generator Functions.
(Optional) Enable sharing of your Data Entities. See Create Shared Folders to learn more.
Add Data Entities to API Monitoring Test
To use your Test Data from shared Data Entities:
Go to the BlazeMeter API Monitoring tab.
Open or create an API Monitoring Test.
Go to Editor > Environment > Test Settings and select Test Data.
Under Test Data Source, select Add Test Data.
In the Account and Workspace input drop-downs, select the Account and Workspace from which to draw your Test Data.
Under Test Data Entities:
Select Add Test Data Entity and choose from the available list of entities.
A preview of your entity will be available under Test Data Preview, and the variables will be listed under Test Steps > Parameterisation.
- (Optional) Add additional entities to use in the test.
(Optional) Configure the Number of Rows and Data variant for each entity.
Tip: If you are using multiple Data Entities, the test will draw the maximum number of data rows that have been specified among the entities. For instance, if you have three Data Entities with 1, 2, and 10 Number Of Rows specified, the test will draw 10 data rows.
Restriction: Depending on your subscription plan, you may be subject to a limited number of data rows. If your specified Number of Rows exceeds the data row limit, the Test Data size will be automatically reduced to match your subscription.
- (Optional) To execute data iterations in sequence instead of in a parallel run, check the Run data iterations sequentially box.
Add Your Parameters
You can now add data parameters using the test data variables in your Request and Assertions sections, much like regular variables. For more information, see Use Variables to Pass Data Between Steps (Chained Requests).
Go to Editor > Steps > Parameterisation to view the available variables from your Data Entities, and add them to Request or Assertions.
Important: API Monitoring uses {{variable}} format.
Run Your Data-driven Test
After uploading and configuring your CSV data file or Data Entities, and adding parameters to your step Request or Assertions, click Run Now.
Tip: Enabling the Run Once option allows you to run a particular step only in the first iteration. For example, this can be useful if your first step is authentication and you only need to authenticate the first iteration, while all subsequent requests will be automatically authenticated.
After enabling, click Save and Run.
View Test Iterations and Individual Data Line Results
For data-driven tests, test results will be grouped in Iterations. Each iteration represents a test execution using a single data line entry from the CSV file or Data Entity.
Each set of Iterations will show a failed count (if any). This represents the number of individual iterations that failed within that group.
Access individual data line result
To view an individual iteration/data line result:
Go into a test and select Results.
Click on View Iterations to show the individual iterations.
Identify the specific iteration by clicking View Test Data.
This will bring up the data line from that particular iteration, as follows:
Tip: Clicking View Test Data next to the test name in the Iterations view will show all the data lines used in all the iterations.
Once you've identified the iteration, click View result.
The individual data line result is shown:
0 Comments