postman 比对是否不相等

本文介绍了如何使用Postman(PM.js)测试API请求,包括检查HTTP状态码、解析JSON响应、验证特定值并更新环境变量。通过示例展示了如何在测试中比较和设置不同的业务ID。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

pm.test("Status code is 200", function () {

    pm.response.to.have.status(200);

});

pm.test("code 200", function () {

    var jsonData = pm.response.json();

    pm.expect(jsonData.code).to.eql(200);

});

console.log(pm.response.json().data.list[1].ruleDetail);

var plantVerifyBusinessId2_before=pm.environment.get("plantVerifyBusinessId2");

console.log(plantVerifyBusinessId2_before);

console.log(pm.response.json().data.list[1].plantVerifyBusinessId);

pm.test("不同",function(){pm.expect(pm.response.json().data.list[1].plantVerifyBusinessId).to.not.equal(plantVerifyBusinessId2_before);});

pm.environment.set("plantVerifyBusinessId2",pm.response.json().data.list[1].plantVerifyBusinessId);

// setTimeout(function() {},[4000]);

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值