Jmeter data driven - csv efficient use case

Table of contents

1. Set the test case and create the use case data file: testcase.csv

2. Create a new thread group, name it: data-driven, add the configuration element - HTTP request default value, configure the IP address and port number

3. Add logic controller - loop controller. The role of the loop controller can control the number of times the entire use case loop is executed. The default value is 1 and can be modified to 8 according to the number of use cases

4. Add CSV data file settings under the loop controller node, the specific configuration content is as follows:

5. Add a logic controller—if (if) controller, the function of the if controller is to execute different use cases according to different conditions. For example, according to different interface request types, add GET and POST controllers respectively.

6. Add request and response assertions under the GET and POST controllers respectively

7. Add a listener - view the result tree, click Run to view the execution results


1. Set the test case and create the use case data file: testcase.csv

Use case name variable meaning:

${caseSeq}:用例编号
${apiType}:api类型
${apiSeq}:api版本号
${apiName}:api名称
${priority}:优先级
${url}:api路径
${methods}:请求方法
${parameter}:请求参数
${expectValue}:期望值,用于断言

Note: In order to avoid garbled characters when JMeter reads CSV files, you should first create an xls file, and then save it as a file in csv format.

2. Create a new thread group, name it: data-driven, add the configuration element - HTTP request default value, configure the IP address and port number

3. Add logic controller - loop controller. The role of the loop controller can control the number of times the entire use case loop is executed. The default value is 1 and can be modified to 8 according to the number of use cases

4. Add CSV data file settings under the loop controller node, the specific configuration content is as follows:

5. Add a logic controller—if (if) controller, the function of the if controller is to execute different use cases according to different conditions. For example, according to different interface request types, add GET and POST controllers respectively.

①The conditional statement set by GET is: "${methods}"=="GET", where ${methods} refers to the value in methods in csv

②The POST condition statement is set to: "${methods}"=="POST"

Note: Interpret Condition as Variable Expression: If this option is selected, js parsing will not be used;

The value of the conditional expression must be true (ignoring case), here we uncheck the state. Evaluate for all children: If this item is selected, the expression will be evaluated before each child node is executed

6. Add request and response assertions under the GET and POST controllers respectively

① Add a use case of the GET request type, the format of the use case name:

${caseSeq}_ ${apiSeq}_${apiName}

Note: The name of the HTTP request is combined with the parameter name of the CSV file, so that the name of each use case will be displayed in the result tree according to the number of the use case, interface name, etc.

②Assertion settings are as follows: ${expectValue} refers to the corresponding value in csv.

③Add a use case of POST request type, use case name format:

${caseSeq}_ ${apiSeq}_${apiName}

④Assertion settings are as follows: ${expectValue} refers to the corresponding value in csv.

⑤If the POST request sends parameters in json format, you need to add a configuration element - HTTP header manager, write name: Content-Type; value: application/json

7. Add a listener - view the result tree, click Run to view the execution results

It is very convenient to set up in Jmeter when faced with a large number of use cases, and the subsequent use case maintenance is also very efficient.

The following are supporting learning materials. For friends who do [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse also accompanied me through the most difficult journey. I hope it can help you too!

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

Information acquisition method:

Guess you like

Origin blog.csdn.net/myh919/article/details/132368627