How to use test data in Apidog?
Getting Started
Create a test scenario and add the necessary test steps.
Prepare the test data. A set of test data is a two-dimensional table, where each column represents a variable, and each row contains a set of values for those fields, to be used for a single test scenario iteration. For example, you can prepare a CSV file with the following data.
Dataset Name | petType | petName | age | price |
---|---|---|---|---|
Pet-1 | Dog | Buddy | 3 | 300 |
Pet-2 | Cat | Whiskers | 2 | 150 |
Pet-3 | Bird | Tweety | 1 | 50 |
Pet-4 | Rabbit | Thumper | 4 | 80 |
Pet-5 | Dog | Max | 5 | 250 |
Switch to "Test Data" tab, click "New" to add a set of test data.
Import the test data, add a name, and save it.
Add the test data variables to your requests. The names of the test data variables should match the column names in the two-dimensional table.
When running the test, select the desired data set.
click Run, and choose the dataset you want to use.
The test report will show the results for each dataset.
Test data
Editing test data
Using test data
{{variable}}
to insert test data variables into the request parameters, headers, body, and other locations. When running the test scenario, these variables will be replaced with the corresponding test data values.Using test data in scripts
pm.iterationData.has(variableName:String)
: function β Boolean: Check whether a test variable exists.pm.iterationData.get(variableName:String)
: function β *: get a test variable.pm.iterationData.replaceIn(variableName:String)
: function: replace dynamic variables in a string with their actual values.pm.iterationData.toObject()
: function β Object: get all local variables as objects.FAQ
UTF-8
encoding.iconv -f GBK -t UTF-8 xxx.csv > utf-8.csv
to convert encoding.Modified atΒ 2024-11-20 11:53:50