梦幻小丑灯 发表于 2023-12-1 11:08:30

Jmeter接口自动化测试 —— Jmeter断言之Json断言

json断言可以让我们很快的定位到响应数据中的某一字段,当然前提是响应数据是json格式的,所以如果响应数据为json格式的话,使用json断言还是相当方便的。还是以之前的接口举例<font size="3">Url: https://data.cma.cn/weatherGis/web/weather/weatherFcst/getCurrentCondition

HTTP Method: Post

Request:
staId: 54511

Response:
{"v01301":"54511","v13003":71,"v12001":24.3,"v13011":0.0,"v11292":229.0,"v11293":1.6,"v20003":5.0,"d_DATETIME":2019,"d_IYMDHM":1566792218000,"d_RECORD_ID":2.08712269E9}
</font>
[*]添加一个Json断言

https://pic3.zhimg.com/80/v2-8e30549755ccd4b0fb622be917c208a2_720w.jpg
[*]维护上想要判断的字段
https://pic4.zhimg.com/80/v2-94152ffaebaa52e0c403e9bf77c95bef_720w.jpg
[*]查看结果
https://pic3.zhimg.com/80/v2-b1a9048946baf459f89041832a20a9b2_720w.webp​我们将期望的值故意改成错的545111看看会不会报错https://pic3.zhimg.com/80/v2-58770a01062fabccda211db9a154b1ea_720w.webp正则表达式https://pic2.zhimg.com/80/v2-216812f3b561d94d65a9d8983b504a01_720w.webp​期望是空https://pic1.zhimg.com/80/v2-340ef9147f819af61fa7132d35c63a7c_720w.webp
页: [1]
查看完整版本: Jmeter接口自动化测试 —— Jmeter断言之Json断言