Platform introduction
A complete interface automation testing platform needs to support automatic execution of interfaces, automatic generation of test reports, and continuous integration. Jmeter supports interface testing, Ant supports automatic construction, and Jenkins supports continuous integration, so the combination of the three can form a fully functional interface automation testing platform.
Environmental preparation
environment dependent
JDK environment configuration
Jmeter installation
Ant installation environment variable configuration
Jenkins installation
Introduction to Ant
Apache Ant, a tool that automates software compilation, testing, deployment and other steps, is mostly used for software development in the Java environment.
Download and install
Download address: https://ant.apache.org/bindownload.cgi
After downloading, unzip it to any file path, and here I put it in the root directory of the C drive.
Environment variable configuration
ANT_HOME C:\apache-ant-1.10.5
Path : %ANT_HOME%\bin
ClassPath %ANT_HOME%\lib
Be careful to use your own path
configuration detection
Enter the following command to check whether the installation is successful
C:\Users\lyh>ant -version
Apache Ant(TM) version 1.10.5 compiled on July 102018
Note: If the prompt 'ant is neither an internal command nor an external command', the environment variable may be misconfigured.
Introduction to 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 to make continuous integration of software possible.
download and install
Download address: https://jenkins.io/download/
After downloading, install it to the specified path. The default startup page is localhots:8080. If port 8080 is occupied and cannot be opened, you can enter the jenkins installation directory, find the jenkins.xml configuration file and open it, and modify the port number of the following code.
PS: If you encounter other problems, please refer to my other two articles
[Jenkins problem solved record] PKIX path construction failed" and "Unable to find a valid certification path for the requested target
Implement Postman+Newman+Git+Jenkins+DingTalk/Email reminder interface automation test continuous integration
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war"--httpPort=8080 --webroot="%BASE%\war"</arguments>
Platform construction
Dependency file configuration
First, create a new folder loadTest under the Jmeter directory (do not use underscores or space characters in the folder name), and place the Jemter test script into this folder.
Put the ant-jmeter-1.1.1.jar from the Jmeter extras file into the lib folder in Ant
Put jmeter-results-detail-report_21.xsl , build.xml , collapse.png , expand.png in the Jmeter extras file under the bin directory in the ant directory .
build.xml configuration
Open the build.xml file in Ant's bin directory and find the following content
<property name="testpath" value="${user.dir}"/>
<property name="jmeter.home" value="${basedir}/.."/>
<property name="report.title" value="Load Test Results"/>
<!-- Name of test (without .jmx) -->
<property name="test" value="Test"/>
Parameter Description
testpath test plan, used here to store test scripts, test generated files, and test reports
jmeter.home Jmeter directory path
report.title The title of the test report
test The name of the jmeter test script (no suffix .jmx required)
Modify it according to your own environment as
<property name="testpath" value="C:\apache-jmeter-5.1.1\loadTest"/>
<property name="jmeter.home" value="C:\apache-jmeter-5.1.1"/>
<property name="report.title" value="Httpbin API Test Report"/>
<!-- Name of test (without .jmx) -->
<property name="test" value="httpbin_test"/>
Ant build
Execute the following command to build
ant -buildfile C:\apache-ant-1.10.5\bin\build.xml
The result is as follows:
Go to the loadTest folder and you can see that the following files are generated:
Open the html test report httpbin_test.html and the content of the report is as follows:
Integration into Jenkins
Create a new task httpbin_Api_test in Jenkins
Select Invoke Ant in the build option and then enter the build.xml configuration file path in Build File. Note: Do not enter it into Targets, you need to click the advanced option to display the Build File
After execution, you can see that the console output is the same as that of cmd
Email message push
Refer to the previous articles
[Jenkins problem solved record] PKIX path construction failed" and "Unable to find a valid certification path for the requested target
to implement Postman+Newman+Git+Jenkins+DingTalk/Email reminder interface automation test continuous integration
Generate report optimization
refer to this article
Report Optimization for Jmeter+Ant+Jenkins Automation Construction