The most complete in history, Jmeter+ant+jenkins interface automation test actual combat (ultra-fine finishing)


foreword

1. Install Jmeter

Download the installation package (skip the process, find the installation package by yourself, and install it in any directory)

Configure environment variables:
JMETER_HOME is the jemter installation path;
CLASSPATH is %JMETER_HOME%\lib;
PATH is %JMETER_HOME%\bin;

Installation verification:
Enter the carriage return in the command window jmeter -v, if the jmeter version appears, it means that the configuration is successful

A1

You can directly enter jmeter in the command window and press Enter to start jmeter; you can also start jmeter between clicking the jmeter.bat file

A2

Debug an interface on jmeter (if there are multiple interfaces, just add it according to the jmeter method)

A3

2. Install jdk

Download the installation package (I am using jdk1.8 version, download it yourself)

Configure environment variables:
JAVA_HOME is C:\Program Files (x86)\Java\jdk1.8.0_171 (Note: I installed java by default on C drive)
CLASSPATH is .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools .jar;
PATH is %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;

Installation verification:
Enter in the command window java -versionand press Enter, if the java version appears, the configuration is successful

A4

3. Install Ant

Download the installation package
Download address: http://ant.apache.org/bindownload.cgi
After downloading, decompress it to the specified location. I put it in the same location as jmeter

A5

A6

Configure environment variables:
ANT_HOME is the ant decompression location
CLASSPATH is %ANT_HOME%\lib;
PATH is %ANT_HOME%\bin;

Installation verification:
verify the installation result, enter the command line ant -v, and if the version information appears, the installation is successful

A7

Ant configures Jmeter: use ant build command to mobilize and execute jmeter interface test and generate test report

Configuration library file:
copy the ant-jmeter-1.1.1.jar file in the jmeter extras directory to the lib folder in the ant installation directory

Configure ant's compilation file build.xml:
create a new txt file, and rename this file to build.xml, and modify the content in the document

Note: There is also a build.xml document under the extras file of jmeter. Do not use this document to modify it. It is two different things. The build document here is created by yourself.

The tab key cannot exist in the code, otherwise the compilation will fail, and the script to be executed must also be specified, otherwise there will be problems.
Modify the following documents according to the actual situation:

A8

A9

Configure the jmeter.propertise document:
find the jmeter.properties document, open the document and edit it in the jmeter/bin directory, and modify the jmeter report output format to xml:

Change jmeter.save.saveservice.output_format=csv to jmeter.save.saveservice.output_format=xml, and remove the previous comment symbol#

A10

Verify the configuration and execute the build test:
save the previous jmeter script, and put the build.xml configuration file in the same directory as the test script. My directory is as follows:

A11

Execute the test

Open the command window in the directory where build.xml is located (press the shift key in the blank space and right click), or command line cd to the directory where the build.xml file is located, enter ant run and press Enter to execute the test

A12

View the test report:
Check whether there are jtl and html result reports under the report output storage path, and the storage path is also in the build document

A13

A14

Open the html document, the test result shows the result parameters such as the name of the executed use case, the success rate, and the execution time of the use case

A15

Is this result not very intuitive, because the test report information obtained by using the test report that comes with jmeter is not very complete. Let me talk about how to optimize the test report

Optimization Test Report

Download the optimized template jmeter-results-shanhe-me.xsl, and copy it to the extras directory of jmeter
Download address: jmeter.results.shanhe.me.xsl

A16

Set the content to be output in the test output report: also in jmeter.properties, set the content to be output to true, and remove the previous comment symbol #, here all set to true → save

A17

Set the report template of the build file to the optimized template jmeter-results-shanhe-me.xsl

A18

Build the test with ant again and view the optimized test report

A19

4. Configure Jenkins and build continuous integration

Download the installation package (the installation process is omitted)

Configure environment variables

JENKINS_HOME 为 C:\Program Files (x86)\Jenkins

Start the Jenkins
browser and enter: http://127.0.0.1:8080/, open jenkins, configure the user name, password and plug-ins, here you need to configure the invoke ant plug-in, the plug-in displayed in the HTML test report

Install HTML Publisher Plugin and Ant In Workspace in Jenkins creation management;
configure jdk and Ant in Jenkins system management - system settings;

A20

A21

Create and configure a project

A22

A23

A24

Note: Ant builds the project. By default, the script under the workspace in Jenkins is executed. If there is no script under the workspace, the build will be fine. My approach is to place both the script and the build.xml file under the workspace directory.

A25

Note: The value of Index page[s]: (TestReport.html) is consistent with the name of the test report set in build.xml, otherwise the test report cannot be viewed in Jenkins.

A26

The script configuration is complete.

On the project home page, click Build Now to execute the test

A27

Continue to build and basically complete, open the test report storage path and you will see the newly generated report document.

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)

Work hard, not afraid of difficulties, every challenge is an opportunity for growth. Go forward with courage and faith, and your efforts will eventually pay off. Believe in your abilities and climb to the top.

Every effort is an accumulation, and every struggle is a transcendence. Believe in your own potential and persevere in pursuing your dreams. Only by moving forward can you discover infinite possibilities. Embrace challenges, meet changes, and strive endlessly.

Persistence is not a choice, but an attitude; struggle is not a short-term enthusiasm, but a persistent effort. In the face of difficulties, show your courage; in the face of challenges, discover your potential. Believe in yourself and go beyond the limit.

Guess you like

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