When using jmeter for interface testing, you must first compile the response interface test case according to the interface definition. When writing interface test cases, we will focus on different tests, use different methods to compile test cases.
One is: the entire request parameter is used as a variable for testing and execution;
One is: each request parameter is used as a variable for testing and execution;
--- A complete interface test case must be written using both of these test cases.
Write the first test case:
1. Write the entire request in a CSV file
For example: (the interface requires two parameters: pageno and DeviceID. Both parameters are required. The following content is required for the complete request :)
2. Use CSV Data Set config to obtain parameters and define them as variables.
(1. Use filename to configure the test case address;
(2) variable names: defines the variable name for future calls during interface requests;
(3. delimiter: depending on the actual configuration, "," is generally used.
----- Here, the information in the test case is read and assigned to the sparamter variable.
You can also define the variable name in the first line of the test case. You do not need to configure the variable name during the CSV call, for example:
3. In the interface, call a variable as a parameter for testing
Because there are three records in the test case, we configure a loop controller before the request to control the invocation interface for three times, for example:
The hierarchical configuration is as follows:
In the HTTP request for "Interface Test", configure the parameters as follows:
In the path, configure the interface path to be tested;
In body data, the sparamter variable defined in CSV is called. Now we have completed the configuration and can execute the test case. View test results:
Because both required parameters are required fields, all three test cases fail to be executed.
Write the second test case:
The procedure is similar to the first one. It is only used to set sub-parameters and call variable calls during case writing.
Use Cases are written as follows:
File variable definition:
Note: Because "" is used in our variables, you need to set "allow quoted data" to true during CSV configuration.
Parameter Variable call:
If you do not need to test whether the parameter value format is determined, you can configure double quotation marks in the parameters. In the test case, only the input is included, not its symbol.
Compiling and calling test cases for jmeter Interface Test Series