Compiling and calling test cases for jmeter Interface Test Series

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.