【发布时间】:2020-07-13 09:55:49
【问题描述】:
所以我的问题是我想对单个 api 调用进行 2 次测试 - 一次通过,一次失败,缺少参数。
这是我所拥有的:
pm.test("Successful Login", function () {
pm.response.to.have.status(200);
});
pm.test("Missing Parameters", function () {
const currentUsername = pm.environment.get("username");
pm.environment.set("username", null);
pm.response.to.have.status(400);
//pm.environment.set("username", currentUsername);
});
如您所见,我在第二次测试中将用户名设置为 null,只是在测试后将其设置回原始值。我发现,邮递员没有按顺序运行脚本,而是在可以运行第一个测试之前将我的用户名设置为 null,所以我第一个测试失败了。我该怎么办?
【问题讨论】:
标签: testing postman postman-testcase