How to make your Jmeter+Ant test report more attractive?

Table of contents

introduction

1. Install apache-Ant

Two, Jmeter preparation

3. Generate test report

4. What is the logic of JMeter dynamic parameter processing?

5. How does JMeter do API automation testing?

epilogue


introduction

Imagine that you toiled to build a complex website, devoting a lot of time and effort to developing and testing it. When you're finally done testing and ready to generate a test report, you might find the process rather tedious, and for others, it might not be that appealing.

But don't give up! Because in this article, we will share how to use Jmeter+Ant to generate test reports and make it more attractive.

JMeter generates test reports using the Ant (Maven) build tool to generate HTML test reports.

[Jmeter Tutorial: Message 777 for free access]

The most detailed JMeter interface test/interface automation test project practical collection tutorial, learning a set of jmeter interface test tutorials is enough! !

1. Install apache-Ant

1. Unzip the apache-ant installation package
ant is a Java language construction tool  Apache Ant - Binary Distributions


2. Configuration environment
①: Copy the path of the bin directory in ant and put it in the Path variable (note that the English semicolon is separated from the previous one)
E:\workplace\Ant\apache-ant-1.9.14\bin

3. Verify Ant is installed successfully
Console command: ant -v

Two, Jmeter preparation

1. Create a new tests folder under the jmeter directory (test scripts and test reports are stored in the tests folder), create a new report and script folder under the tests folder, and then create a new html and jtl folder under the report folder 2. Put
jmeter The saved test script is saved to the script
directory structure as shown below:

把jmeter下的extras文件下的ant-jmeter-1.1.1.jar复制,粘贴到ant下的lib文件中

编写build.xml文件,把build.xml放在jmeter的tests的文件下

在jmeter的bin目录下找到jmeter.properties用记事本打开,CTRL+F找到#jmeter.save.saveservice.output_format=csv,然后把井号取消,等号后面改为xml

activation.jar, commons-email-1.2.jar,   mail.jar,这三个文件放在ant的lib目录下

完善build.xml文件:
build.xml文件定义了
A、执行哪个测试脚本
B、实现自动发送脚本(邮箱)
C、自动生成测试报告

	定义jmeter地址 加上接受报告的qq邮箱 要执行的测试脚本的名字 自动生成测试报告
	在控制台进入到tests,输入ant,这时在report下的html中,会有测试报告

Put build.xml under jmeter's tests file:



3. Generate test report

The condition for ant execution is to have a build.xml file. There are three main contents in the build.xml file:
1. Define the test script to be executed
2. Define the directory of the test report
3. Define the automatic sending of emails

HTTP COOKIE manager (SESSION session object -- "code level):
1. The COOKIE between all requests is shared
2. While the COOKIE between all requests is shared, the underlying TCP connection is only established once

11 indicates that the first matched value is assigned to the reference name.


4. What is the logic of JMeter dynamic parameter processing?

Taking login as an example, the TOKEN returned after a successful login is different each time, and this value is a dynamic parameter, so the TOKEN needs to be called in the interface after a successful login (such as the home page): 1. In the login
interface Add the JSON extractor in the post-processor, define a variable to obtain the value of the token returned after successful login
2, call this variable through ${} in the next interface (such as the home page)
3, execute the tasks in the thread group, It is possible to realize the upper and lower correlation of parameters

Commonly used components:
1. HTTP header manager
2. COOKIE manager
3. View result tree
4. JSON extractor/regular expression extractor
5. JSON assertion and response assertion
6. HTTP request default value
7. User-defined Variables (separated from public data)

5. How does JMeter do API automation testing?

1. First, create a test plan in JMeter, and create a thread group in the test plan.
2. Add HTTP requests in the thread group, and add API test cases
. 3. After writing the test case, combine the Ant construction tool to write build. xml file (execute script, test report directory, automatically send email)
4. Execute ant in the directory of the build.xml file,
and it will be automatically executed. Click build to automate execution

How do you test for a service?
1. Normal function
2. Abnormal function
A. The request parameter must be filled in, but it is not included. Whether the background has made a judgment
B. Whether the data type of the request parameter has been judged
C. A specific parameter requires a specific value
D. The request parameter exceeds the length 3.
Security testing, mainly refers to whether the service has been authenticated and authorized
4. Performance testing (how many people can access this service at the same time)
5. Stability testing (refers to verifying the stability of a service)

epilogue

This post ends here, and finally, I hope that friends who read this post can gain something.

 How to get it: Leave a message [Jmeter Learning Tutorial]

If you think the article is not bad, please like, share, and leave a message , because this will be the strongest motivation for me to continue to output more high-quality articles!

Guess you like

Origin blog.csdn.net/weixin_67553250/article/details/130791639