简体   繁体   English

如何通过脚本在POSTMAN CollectionRunner中设置失败

[英]How to set failed in POSTMAN Collection runner via script

How can I set a "FAILED" via script? 如何通过脚本设置“失败”? I have a IF and in this if I want to check is X compare to Y. If not I want to get an "FAILED". 我有一个IF,如果要检查X是否与Y比较。如果不是,我想得到“ FAILED”。 For now I get an "FAILED" in my console but the test is "PASS". 现在,我的控制台中显示“ FAILED”,但测试为“ PASS”。 I already searched other sites but found nothing about this. 我已经搜索了其他站点,但未找到任何相关信息。 Hope u now what I mean. 希望你现在我的意思。

   if(pm.iterationData.get("ProfileSeries") == response.ProfileSeries){
    console.log("expProfileSeries " + pm.iterationData.get("ProfileSeries") + " = "+ response.ProfileSeries);
    }
    else{
         console.log("FAILED");
}

Add pm.test with relevant pm.expect : 添加pm.test和相关的pm.expect

pm.test('ProfileSeries should be equal', function () {

pm.expect(pm.iterationData.get("ProfileSeries")).to.equal(response.ProfileSeries);

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在脚本中设置if else语句 - How to set if else statement in script 如何正确设置“if”条件 App Script - how to set “if” criteria correctly App Script 如何在其他条件下通过 Jenkins 中的 shell 脚本中止构建 - How to abort build via shell script in Jenkins within if else condition 如何通过代码在StimulSoft中设置Text元素的文本? - How to set text of Text element in StimulSoft via code? 收集Groovy中的自定义数字字段,并计算返回结果(JIRA脚本运行器) - Gathering custom number fields in Groovy, and calculating return result (JIRA script runner) 如何根据数组中的值在邮递员中编写条件语句 - How to Write a conditional statement in postman based on a value in an array 检查是否设置了cookie,如果没有则输出脚本 - Checking if there is a cookie set, if not output script 如果设置了参数,bash脚本将被拆分 - bash script split if argument set 使用选择选项时如何设置输入值? Java脚本与if - How to set value of the input when I use select option? Java script with if 如何使用批处理脚本重命名在该文件夹中具有一定数量文件的多个文件夹? - How to rename multiple folders that have a set number of files within that folder using batch script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM