让我们定期进行测试:
col1 col2 overlap_count
0 20 39 x
1 23 32 x
2 40 42 x
3 41 50 1
4 48 63 1
5 49 68 2
6 50 68 3
7 50 69 3
我需要使用变量自定义语句:
pm.test("response is ok", function () {
pm.response.to.have.status(200);
});
其中CustomerNumber是已定义的环境变量。
我尝试使用{{$ CustomerNumber}},但似乎无济于事,它会引发错误。
答案 0 :(得分:0)
尝试一下。为我工作。
pm.test("response for Customer Number" + pm.environment.get("CustomerNumber") + " is ok", function () {
pm.response.to.have.status(200);
});
答案 1 :(得分:0)
很遗憾,它无法正常工作。
我的网址是: https://tapy-uat.flyrit.de/clm/unbprocessor/sales/pt/identifiers/no= {{path}}
我使用数据输入文件:
path
4567459687
4357349584
2396504398
4572839495
当我使用常规测试语句在Collection Runner中执行时:
tests["Status Code is correct"] = responseCode.code == '200';
它执行得很好。如果我这样定制测试语句:
pm.test("response for Customer Number " + {{path}} + " is ok", function () {
pm.response.to.have.status(200);
});
它答复
"response for Customer Number undefined is ok"
但是测试响应为“绿色”,因此只是错误的文本。
总是在加载数据输入文件后总是从Collection Runner执行。
从Collection Runner执行而文本中没有变量的情况执行得很好。
答案 2 :(得分:0)
路径不是环境变量,因为它是在运行时从Collection Runner中的数据输入文件中读取的。
将其包含在URL中就可以了:
https://tapy-uat.flyrit.de/clm/unbprocessor/sales/pt/identifiers/no={{path}}
并在运行时阅读。
所以我无法理解为什么在测试语句中以相同的方式将其显式显示不起作用:
pm.test("response for Customer Number" + {{path}} + " is ok", function () {
pm.response.to.have.status(200);
});
或
pm.test("response for Customer Number" + {{$path}} + " is ok", function () {
pm.response.to.have.status(200);
});