测试中的调试输出

时间:2015-07-01 09:35:06

标签: javascript testing logging postman

如何在Postman测试中输出一些信息?

console.log(tv4.error);
tests["Valid Data1"] = tv4.validate(data1, schema);

console.log()似乎正在工作,但我想将我的信息输出到我的断言所在的同一个面板中(为了更容易相关):

enter image description here

7 个答案:

答案 0 :(得分:48)

做一个通过的假测试:

var jsonData = JSON.parse(responseBody);
tests["id = " + jsonData.id] = true;              // debug message
tests["name = " + jsonData.name] = true;          // debug message

答案 1 :(得分:10)

仅供使用Chrome开发人员工具的人员参考(可让您查看控制台输出并为您提供更多功能)

启用它

  1. 在Chrome网址窗口中输入chrome://flags
  2. 搜索“调试打包应用”设置
  3. 启用设置
  4. 重新启动Chrome
  5. 您可以通过右键单击Postman内的任何位置并选择“检查元素”来访问“开发人员工具”窗口。

      

    您也可以转到chrome://inspect/#apps,然后点击“检查

    Reference

答案 2 :(得分:8)

我用过这个,这不是最漂亮的,但它适用于我需要的东西。

tests["your test name here " + data.data.length] = data.data.length > 100;

答案 3 :(得分:0)

其中一种方法是使用测试[“”+值]。

例如

http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=Your_API_Key

回应:

  

Blockquote

答案 4 :(得分:0)

Pi带其他答案,只需在Postman测试代码中定义一个函数

var print = function(s){
  tests[s] = true;  
};

然后像食用

print("current value of x: " + x);

答案 5 :(得分:0)

类似于先前关于替代选项的答案:使用开发工具。但是,如果您使用的是本机应用程序,则右键单击以获取开发工具将不起作用。

相反,

  1. 转到应用程序菜单中的“查看”,然后单击“显示DevTools”。
  2. 在“ DevTools”窗口中,单击顶级控制台选项卡,应显示该应用程序的调试日志。

参考:https://learning.getpostman.com/docs/postman/collection_runs/debugging_a_collection_run

答案 6 :(得分:0)

现在您已经有了一个名为“邮递员控制台”的东西,要运行它,请键入CTRL + ALT + C 有关更多信息,请参见此处:https://blog.getpostman.com/2016/08/26/the-postman-console/

相关问题