Interface automation test based on Jmeter+ant+Jenkins+DingTalk robot group notification

foreword

There are some prerequisites for building the jmeter+ant+jenkins environment, that is, the java environment must be configured first. The local java environment is at least JDK8 and above, preferably a higher java environment such as JAVA11 or JAVA17, and a continuous construction tool like jenkins Basically, they are upwardly compatible with the JAVA environment. The previous JAVA8 or lower versions may have exceptions when running jenkins, etc., resulting in execution failure or prompting that the java version is too low and needs to be updated. It is recommended to install two sets of JAVA environments in the local computer environment, one JAVA8, a JAVA17, you can switch the JAVA version according to the configured environment variables when you need to use it

jmeter: open source interface and stress testing tool, developed based on java, running requires java environment

ant: Apache Ant is a tool that automates steps such as software compilation, testing, and deployment, and is mostly used for software development in the Java environment. Ant needs an XML file (build file) when running, and a java environment is required for running

jenkins: Jenkins is an open source software project. It is a continuous integration tool developed based on Java. It is used to monitor continuous and repetitive work. It aims to provide an open and easy-to-use software platform, so that software projects can be continuously integrated. Java is required to run environment

1. Install and configure the local JAVA environment, install JAVA8 and JAVA17

Download JAVA8 and JAVA17 versions respectively, download from JAVA official website, address:

https://www.oracle.com/java/technologies/downloads/#jdk20-windows


Choose to download JDK17 according to the above address, install the windows version, and install the historical version of JAVA8 by downloading and installing it yourself

If I have installed JDK8 and JDK17 locally, the installation path is as follows:


After installing JAVA8 and JAVA17 locally, in order to switch between the two versions, you need to configure the following environment variables respectively:

1. Variable name: JAVA_HOME Value: %JAVA_HOME17%, if you need to switch to JAVA8, change the value to: %JAVA_HOME8%


2. Variable name: JAVA_HOME8 Value: C:\Program Files\Java\jdk1.8.0_91, the value is the local JAVA8 installation path


3. Variable name: JAVA_HOME17 Value: C:\Program Files\Java\jdk-17, the value is the local JAVA17 installation path


4. Variable name: CLASSPATH Value: .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%ANT_HOME%\lib;

5. Variable name: PATH, move the value: %JAVA_HOME%\bin to the front

insert image description here
After the above environment variables are configured, open cmd and check the current version of JAVA, the following can be displayed:


The above shows that the current environment is JAVA17. If you switch to JAVA8, modify the variable name: JAVA_HOME and change the value to: %JAVA_HOME8%, then open cmd again to view the running version of JAVA:

2. Install and configure Jmeter

Download and install from the official website. After installation, configure the GUI interface that can start jmeter normally to develop interfaces and scripts.

3. Install and configure ant

Ant download address: http://ant.apache.org/

Just download the latest ZIP archive, as shown below:


Version: 1.10.13 The official website clearly states that the operating environment of JAVA8 and above is required, and the JAVA environment lower than JAVA8 needs to be upgraded

After downloading and decompressing under the local specified path, configure the environment variables as follows:

ANT_HOME:F:\apache-ant-1.10.13-bin\apache-ant-1.10.13

path:%ANT_HOME%\bin;

classpath:%ANT_HOME%\lib;

After the configuration is complete, check the ant version in the cmd window, and the display is as follows, that is, the ant installation is ok

Four, jmeter + ant configuration

Package the jar of ant-jmeter-1.1.1 under apache-jmeter-5.4.1\extras to the lib directory of ant, as shown below:


2. Under a local disk path, create a new xml file: build_test.xml, such as my path: D:\apache-jmeter-5.4.1\test

xml file, the content is as follows:


The specified content in the xml file can be modified according to the actual configuration

At the same time, place the jmx script file that needs to be executed in this directory

3. Modify the jmeter.properties configuration under jmeter

jmeter.properties configuration file path: D:\apache-jmeter-5.4.1\apache-jmeter-5.4.1\bin

Change jmeter.save.saveservice.output_format=csv to: jmeter.save.saveservice.output_format=xml


4. Run in cmd window

Cmd switches to the directory of the xml file and executes the command: ant -buildfile build_test.xml

The execution result shows that the build is successful, that is, the jmeter and ant environment configurations are ok


After the build is successful, the html and jtl files will be generated in the directory where the xml file is located, as shown in the figure below:


At the same time, you can view the html test report on jenkins, as shown below:

insert image description here
insert image description here
At the same time, the DingTalk group will also push build notifications, as shown in the figure below:

Timed build effect:


This is done

Deployment and automatic construction of the interface automation test environment notified by Jmeter+ant+Jenkins+DingTalk robot group, and then only need to use jmeter to complete the design and scripting of interface test scenarios and test cases


Public account fan benefits

  • Get a full set of software testing resources for free

  • Software testing interview question brushing applet is free to use

  • Free use of GPT exclusively for testers

insert image description here

Guess you like

Origin blog.csdn.net/weixin_56331124/article/details/131069584