如何在 Postman 中显示断言消息?
How to show Assertion message in Postman?
我在 Postman 中有这段代码,我在其中放置了消息“Rates are close”。您如何在下面屏幕截图中蓝色矩形突出显示的部分的 运行 结果中显示消息“价格接近”?
pm.test("TestPricing",function(){
pm.expect(RateFromData).to.closeTo(rateActualResult,0.01,"Rates are close");
});
Screenshot of my collection Runner
只有在测试失败时才抛出断言消息,通过时不会抛出断言消息,绿色表示测试通过。
让测试名称更具描述性:
pm.test(`Expect price to be close to ${rateActualResult} with max delta difference of ± 0.01`,function(){
pm.expect(RateFromData).to.closeTo(rateActualResult,0.01,"Rates are close");
});
输出:
通过:
失败:
我在 Postman 中有这段代码,我在其中放置了消息“Rates are close”。您如何在下面屏幕截图中蓝色矩形突出显示的部分的 运行 结果中显示消息“价格接近”?
pm.test("TestPricing",function(){
pm.expect(RateFromData).to.closeTo(rateActualResult,0.01,"Rates are close");
});
Screenshot of my collection Runner
只有在测试失败时才抛出断言消息,通过时不会抛出断言消息,绿色表示测试通过。
让测试名称更具描述性:
pm.test(`Expect price to be close to ${rateActualResult} with max delta difference of ± 0.01`,function(){
pm.expect(RateFromData).to.closeTo(rateActualResult,0.01,"Rates are close");
});
输出:
通过:
失败: