当前位置:网站首页>How many assertion methods are commonly used in JMeter?
How many assertion methods are commonly used in JMeter?
2022-08-04 08:02:00 【Program Yuanyuexia】
A feature that is often used in performance testing or interface automation testing using Jmeter is assertion.Assertion is to add a layer of judgment mechanism to the return level of the request.Because the request is successful, it does not mean that the result is necessarily correct, so a judgment mechanism is needed to improve the accuracy of the test.This article mainly introduces three commonly used assertions: response assertion, JSON assertion, and assertion duration.
1. Response Assertion
Response assertion is the most commonly used assertion method. It mainly asserts the text content in the response result, such as whether the response result contains the specified value, or whether it is equal to the specified value.Response assertions can be applied to response results of various return types, such as Test, html, application/json, application/xml, etc.
1: Case
Send request:
Assertion Check: Check whether the response result contains the text content of "Lemon Class Software Test"
2: Operation steps
Step 1: Add a thread group
Step 2: Add HTTP Request

Step 3: Add response assertion under HTTP request

Step 4: Add Assertion Results and Add View Results Tree
Step 5: After running the interface, view the assertion result and view the result tree


Second, JSON assertion
JSON assertion is also an assertion method often used in testing work. It is generally used to assert whether a field value is equal to the value we specify.Therefore, JSON assertion can only be asserted for the response result in applicaton/json format.If it is other types (such as: Test, html), this method cannot be used.
1: Case
Send request: http://47.115.15.198:7001/smarthome/login --login interface
Assertion check: Check whether the content corresponding to the user_name node in the response data is "lemonn"
2: Operation steps
Step 1: Add a thread group
Step 2: Add HTTP Request

Step 3: Add response assertion under HTTP request

Step 4: Add Assertion Results and Add View Results Tree
Step 5: After running the interface, view the assertion result and view the result tree


Three. Duration Assertion
Assertion duration is usually used for performance testing, generally used to check whether the response time of HTTP requests exceeds the expected value.And this response time is a performance indicator that is often concerned in performance testing.
1: Case
Send request: https://www.baidu.com/ --Baidu official website interface
Assertion Check: Check if the response time is less than 200ms
2: Procedure
Step 1: Add a thread group
Step 2: Add HTTP Request

Add image comment, no more than 140 characters (optional)
Step 3: Add response assertion under HTTP request

Step 4: Add Assertion Results and Add View Results Tree
Step 5: After running the interface, view the assertion result and view the result tree


Jmeter's assertion method, do you know it?Below is some test data, free to share

边栏推荐
猜你喜欢
随机推荐
js异步变同步、同步变异步
关于常用状态码4XX提示错误
新特性解读 | MySQL 8.0 在线调整 REDO
New Questions in Module B of Secondary Vocational Network Security Competition
实现加载驱动、得到数据库对象、关闭资源的代码复用,将代码提取到相应的工具包里边。优化程序
data:image/jpg;base64格式数据转化为图片
Use of MotionLayout
解决报错: YarnScheduler: Initial job has not accepted any resources
金仓数据库KingbaseES客户端编程接口指南-JDBC(7. JDBC事务处理)
研究性学习专题 3_LL(1)语法分析设计原理与实现
LLVM编译技术应用分析
Distributed Computing Experiment 4 Random Signal Analysis System
分布式计算实验3 基于PRC的书籍信息管理系统
金仓数据库KingbaseES客户端编程接口指南-JDBC(8. JDBC 元数据处理)
七牛云上传图片和本地上传
沃尔玛、阿里国际该如何做测评自养号?
金仓数据库KingbaseES客户端编程接口指南-JDBC(5. JDBC 查询结果集处理)
GBase 8c数据库集群中,怎么替换节点呢?比如设置A节点为gtm,换到B节点上。
【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解
【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解









