Interface test - Jmeter reads database data as test parameters

Table of contents

1. Add Jdbc Request

2. Add ForEach controller (right-click thread group->logic controller->ForEach controller)

3. Add a login request under the ForEach controller and make a variable reference

4. After running, check the results, successfully obtained 10 user mobile numbers from the library, and successfully logged in respectively

5. Add a jdbc request, query the total number of users in the user table, and set the variable count

6. Set the End index for loop value of the ForEach controller

7. Click Run to check the result successfully


1. Add Jdbc Request

2. Add ForEach controller (right-click thread group->logic controller->ForEach controller)

①Input the prefix of the variable: mobilephone;

From the variables set by jdbc request, we know that the values ​​we want to take are mobilephone_1, mobilephone_2, mobilephone_3... so enter mobilephone here

②Start index for loop:0

The index of the start of the variable loop, the first element start index + 1End index for loop: 6; the index of the end of the variable loop. So here are the values ​​mobilephone_1, mobilephone_2, ..., mobilephone_10

③ Output variable name: t_phone; variable used to replace the request under the loop

3. Add a login request under the ForEach controller and make a variable reference

4. After running, check the results, successfully obtained 10 user mobile numbers from the library, and successfully logged in respectively

For the above processing, you need to check the library by yourself to know how many users there are in total, and then set the End index for loop value of the ForEach controller (set to the total number of users), and then you can log in all users in the library by passing parameters;

But can Jmeter automatically know the number of users in the database table, and then go to loop the value to log in?

Of course, you can use the jdbc request to find out the number of users first, and then directly set the End index for loop value of the ForEach controller.

5. Add a jdbc request, query the total number of users in the user table, and set the variable count

6. Set the End index for loop value of the ForEach controller

7. Click Run to check the result successfully

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/jiangjunsss/article/details/132327125