当前位置:网站首页>Jmeter中的断言使用讲解
Jmeter中的断言使用讲解
2022-06-25 08:08:00 【fish_study_csdn】
一、JMeter断言
1.1 断言的概念
断言:让程序判断预期结果和世界结果是否一致
提示:JMeter断言是在请求的返回层面增加一层判断机制:因为请求成功了,并不代表结果一定正确,因此需要检测机制提高测试准确性
1.2 JMeter中常用断言
(1)响应断言
(2)JSON断言
(3)持续时间断言(Duration Assertion)
二、响应断言
添加方式:测试计划-->线程组-->HTTP 请求-->(右键添加)断言-->响应断言
配置:
(1)测试字段:需要检查的字段

2)模式匹配规则:需要使用什么规则来进行检查:正则、与、或、非、等于
| 测试字段 | |
| 响应文本 | 响应体里的关键字 |
| 响应代码 | 响应码,200 |
| 响应信息 | 响应码后面的返回的信息,OK |
| Response Headers | 测协议的时候用,一般测业务都不使用这个 |
| Request Headers | |
| URL样本 | 发出去的内容,一般也不检查,都是看响应的内容 |
| Document(text) | 检查text格式的文本 |
| Ignore Status | 测试异常的场景,判断错误的响应时的状态,结果不标红 |
| Request Data | |
包括 | 正则 |
| 匹配 | 正则 |
| 等于Equals | |
| 包含Substring | 否、或者、且 |
(3)测试模式:需要校验的值,可以填写多个值进行比较
如:请求:https://www.baidu.com
检查:让程序检查响应数据中是否包含“百度一次,你就知道”
操作步骤:
(1)添加线程组
(2)添加HTTP请求
(3)添加响应断言:HTTP请求-->添加-->断言-->响应断言 
(4)添加断言结果:线程组-->添加-->监听器-->断言结果

(5)添加查看结果树
三、JSON断言
该组件用来对JSON文档进行验证,验证步骤如下:
1.首先解析JSON数据,如果数据不是JSON,则验证失败
2.使用Jayway JsonPath 1.2.0中的语法搜索指定的路径。如果找不到路径,就会失败
3.如果在文档中找到JSON路径,并且要求对期望值进行验证,那么它将执行验证操作
操作方式:测试计划-->线程组-->HTTP请求-->(右键添加)断言-->JSON 断言
操作步骤
1.添加线程组
2.添加HTTP请求
3.添加JSON断言
适用于HTTP响应为JSON格式
配置:
(1)JSON PATH:$.msg
(2)勾选“Additional assert value”
(3)expected value 里填写 查询成功

4.添加断言结果
5.添加查看结果树(一次错误的和一次成功的)

边栏推荐
- QSS buttons of different styles
- 从别人库里拷贝的游戏如何再自己的库里显示
- nodejs 使用Express框架demo
- Various synchronous learning notes
- IC研发常用英文术语缩写
- 一、单个神经元网络构建
- What is the file that tp6 automatically executes? What does the tp6 core class library do?
- 《乔布斯传》英文原著重点词汇笔记(三)【 chapter one】
- [operation tutorial] how does the tsingsee Qingxi video platform import the old database into the new database?
- How to choose an account opening broker? Is it safe to open an account online?
猜你喜欢

Emergency administrative suspension order issued Juul can continue to sell electronic cigarette products in the United States for the time being

City Chain technology platform, really Realizing value Internet reconstruction!

Meaning of Jieba participle part of speech tagging

Analysis of a video website m3u8 non perceptual encryption

关于I/O——内存与CPU与磁盘之间的关系

软件测试月薪10K如何涨到30K,只有自动化测试能做到

C language: count the number of words in a paragraph

Cazy eight trigrams maze of Chang'an campaign
![[515. find the maximum value in each tree row]](/img/0d/7ae494a5b3df3917ab95ebf61a1c96.png)
[515. find the maximum value in each tree row]

【OpenCV】—离散傅里叶变换
随机推荐
2021 "Ai China" selection
linux中的mysql有10061错误怎么解决
C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large
一、单个神经元网络构建
ICer必须知道的35个网站
View all listening events on the current page by browser
Openfoam: bottom layer
关于I/O——内存与CPU与磁盘之间的关系
A 35 year old Tencent employee was laid off and sighed: a suite in Beijing, with a deposit of more than 7 million, was anxious about unemployment
声纹技术(一):声纹技术的前世今生
RTOS 多线程下hardfault问题总结
What is the role of software validation testing? What is the price of the confirmation test report?
TrendMicro:Apex One Server 工具文件夹
Unknown table 'column of MySQL_ STATISTICS‘ in information_ schema (1109)
To achieve good software testing results, it is a prerequisite to build a good testing environment
对常用I/O模型进行比较说明
Sharepoint:sharepoint server 2013 and adrms Integration Guide
jmeter中csv参数化
What is the file that tp6 automatically executes? What does the tp6 core class library do?
Is it safe to buy stocks and open accounts through the account QR code of the account manager? Want to open an account for stock trading