当前位置:网站首页>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

边栏推荐
猜你喜欢
随机推荐
全国职业院校技能大赛网络安全竞赛之应急响应
【论文笔记】—低照度图像增强—Supervised—RetinexNet—2018-BMVC
使用腾讯云发送短信 ---- 手把手教你搞定所有步骤
2022的七夕,奉上7个精美的表白代码,同时教大家改源码快速自用
【并发】概念
redis stream 实现消息队列
金仓数据库KingbaseES客户端编程接口指南-JDBC(7. JDBC事务处理)
Typora颜色公式代码大全
高等代数_证明_对称矩阵属于不同特征值的特征向量正交
使用GBase 8c数据库的时候,遇到这种报错
C语言指针
The sorting algorithm including selection, bubble, and insertion
CSDN21天学习挑战赛——day1 正则表达式大总结
【UE虚幻引擎】UE5三步骤实现AI漫游与对话行为
设计信息录入界面,完成人员基本信息的录入工作,
a标签下载图片,不要预览
金仓数据库KingbaseES客户端编程接口指南-JDBC(9. JDBC 读写分离)
电脑系统数据丢失了是什么原因?找回方法有哪些?
七夕情人节:中英文祝福短信送给你
第一次用postgreSQL,想装主从,用的12.7 tar.gz版本。安装好后没在 share目录下找到样例配置recovery.conf.sample,是安装方式不对,还是路径不对?
![玩转TypeScript对象、对象作为参数进行函数传递、接口和内置对象[无敌态]](/img/23/3405b488d11a4700a9b47758214574.png)






![[想要访问若依后台]若依框架报错401请求访问:error认证失败,无法访问系统资源](/img/aa/701fef9d8d7eaf25082e1289799b77.png)

