
1.在Tests标签中,选中Status Code:code is 200,生成对应代码 2.适当调整test0方法参数1,和匿名函数中的预期结果。 3.点击send按钮,发送请求,执行断言代码。
//断言响应状态码是否为200
pm.test("status code is 2oo",function(){
pm.response.to.have.status(200);
)};
D;
pm:代表postman的一个实例
test():是pm实例的一个方法。有两个参数
参数1:在断言成功后,给出的文字提示。可以修改。"statuscodeis200"
参数2:匿名函数。
pm.response.to.have.status(200);
//意思:postman的响应结果中应该包含状态码 200