Postman 中不同类型的断言
Postman中有不同类型的断言。我们可以在收到的响应的不同部分添加断言。下面列出了一些断言类型-
响应代码断言
pm.test["Status Code is 200"], function(){
pm.response.to.have.status(200)
})如果响应代码为200,则上述断言通过。
pm.test["Status is OK"], function(){
pm.response.to.have.property('status', ' OK')
})上述断言应用于Response属性-值为OK的状态。
响应时间断言
pm.test("Response time below 600 milliseconds", function () {
pm.expect(pm.response.responseTime).to.be.below(600)
})如果响应时间低于600毫秒,则上述断言通过。
响应格式断言
pm.test("响应为JSON类型 ", function(){
pm.response.to.be.json;
})如果Response是JSON类型,则上述断言通过。
对响应头断言
pm.test("Header Of Response", function () {
pm.response.to.have.header("Content-Encoding")
})如果Response具有Content-EncodingHeader,则上述断言通过。
对响应文本断言
pm.test("Response", function () {
pm.expect(pm.response.text()).to.include("Postman")
})如果Response包含文本Postman,则上述断言通过。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下