Popular on the whole network, JMeter interface automation test detailed actual combat (super detailed) hematemesis finishing...


foreword

JMeter interface automation test: https://www.bilibili.com/video/BV19b4y1t79V/

Software download
1, JDK 1.8 or above: Java Downloads | Oracle
2, Apache tomcat 7.0: Apache Downloads
3, JMeter-2.9: Apache Downloads

Software installation and setting environment variables

I wrote it before, you can refer to: JMeter installation tutorial ------details

1. The JDK installation directory is in C:\Program Files\Java (it can also be installed on other disks).
Its environment variable is set to:
JAVA_HOME value: C:\Program Files\Java\jdk1.7.0_21
CLASSPATH value: .;%JAVA_HOME%\lib;
Path value: %JAVA_HOME%\bin;

2. Apache tomcat installation directory is in C:\Program Files\Apache Software Foundation\Tomcat 7.0

3. JMeter installation
Step 1: Unzip the apache-jmeter-2.9.zip file to the c drive.

Step 2: Select "My Computer" (right click)/Advanced/Environment Variables on the desktop, click "New" in the "System Variables" column, enter: JMETER_HOME in the variable name, and enter: C:\JMeter2 in the variable value .9 , click OK.

Step 3: Modify the CLASSPATH variable and add the following value to the variable value:
%JMETER_HOME%\lib\ext\ApacheJMeter_core.jar;%JMETER_HOME%\lib\jorphan.jar;%JMETER_HOME%\lib\logkit-1.2.jar; Then OK.

Step 4: Check if the JMeter installation is OK.
Enter the bin folder C:\jmeter\apache-jmeter-2.9\bin under the JMeter directory, click jmeter.bat, and check the page display. If the JMeter operation page can be displayed, the installation is successful.

Jmeter interface automation test steps

1. Add a thread group: Right-click on the "Test Plan" –> Add –> Thread (User) –> Thread Group

Please add a picture description

Please add a picture description

The number of threads is generally consistent with the number of data items in the csv file

2. Create a new user-defined variable, in the test plan - add - configuration element - user-defined variable. In it, you can define the domain name and port of the project, so you don’t need to fill in every interface later.

Please add a picture description

Please add a picture description

3. Create a new http default request value, in the test plan - add - configuration element - http default request value.

Please add a picture description

Please add a picture description

Please add a picture description

IP and port can be used in the definition variable

4. Add the result tree, in the test plan - add - listener - view the result tree.

Please add a picture description

5. Create an http request under the thread group, in the thread group - add - sampler - http request. You need to fill in the request method, interface path, and encoding. Fill in the parameters in the message body data, the specific value can be the data in the csv file

Please add a picture description

Please add a picture description

6. Add http information header management, in the thread group - add - configuration element - http information header management. The content inside is defined by the interface document, and you can fill in whatever value the headers need, but if the request data is in json format, you must fill in content-type.

Please add a picture description

7. Add csv data file settings, in thread group – add – configuration element – ​​csv data

Please add a picture description

Please add a picture description

File name: the path of the csv file, file encoding: choose utf-8 if there is Chinese in the file, variable name: one-to-one correspondence with each column in the file.

8. Add an assertion, in the thread group - add - assertion - json assertion.

Please add a picture description

Use the interface extracted by the json expression to return the value in the result;
the expected value, use the variable to get the expected value in the csv file, and then make an assertion;

Interface dependency resolution

For example, other interfaces depend on the login token
1. Create a new setup thread group, in the test plan - add - thread (user) - setup thread group.

Please add a picture description

2. Create a new http request, in the setup thread group – add – sampler – http request

Please add a picture description

The data in the message body can be defined in the user-defined variable, just access the variable value directly

3. Create a new json extractor to get the token. In http request – add – post processor – json extractor

Please add a picture description

Name the variable value;
json expression, extract the token in the information returned by the login interface

4. Create a new Beanshell post-processing program to make token a global variable. In http request – add – post processor – Beanshell post processor

Please add a picture description

The expression in the figure is; set token as a global variable and name it Token

5. Other interfaces that need to rely on token can be set in the http information header management, and then they can be accessed

Please add a picture description

The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled

1. From entry to mastery of Python programming

Please add a picture description

2. Interface automation project actual combat

Please add a picture description

3. Actual Combat of Web Automation Project

Please add a picture description

4. Actual Combat of App Automation Project

Please add a picture description

5. Resume of first-tier manufacturers

Please add a picture description

6. Test and develop DevOps system

Please add a picture description

7. Commonly used automated testing tools

Please add a picture description

Eight, JMeter performance test

Please add a picture description

9. Summary (little surprise at the end)

As long as you have a dream in your heart, please bravely pursue it. Don't be afraid of failure, because failure is the mother of success; don't be afraid of falling, because falling will make us stronger. Believe in yourself and fight for your dreams!

Everything in the world has its destiny, and only those who strive can change their destiny. Let us continue to work hard, meet challenges, and forge ahead with sweat and wisdom. As long as we persevere, success will belong to us!

As long as you have faith and keep your feet on the ground, you can surpass yourself and create brilliance. Let us continue to pursue progress, bravely climb the peak, and fearless challenges! Believe in yourself and fight for your dreams!

Guess you like

Origin blog.csdn.net/shuang_waiwai/article/details/130387398