美文网首页
(转载)编写自动执行postman的脚本

(转载)编写自动执行postman的脚本

作者: 7b7d23d16ab5 | 来源:发表于2020-01-31 20:06 被阅读0次

    编写自动执行postman的脚本

    原文链接:https://www.cnblogs.com/yecaiye/p/11585969.html

    1.需要安装newman,newman的安装需要借助Node.js;
    所以先安装好Node.js,然后配置好Node.js的环境;
    安装Node.js,参考资料: https://www.cnblogs.com/zhouyu2017/p/6485265.html
    安装newman,参考资料: https://blog.csdn.net/suancai1993/article/details/76177356?utm_source=blogxgwz5

    npm install -g newman
    

    2.还需要安装一个newman-reporter-html的组件

    执行以上生成html报告的命令时,若出现异常提示:
    newman: "html" reporter could not be loaded.
    run npm install newman-reporter-html

    则需要执行命令npm install -g newman-reporter-html来全局安装支持Newman生成html报告的组件

    npm install -g newman-reporter-html
    

    参考资料:https://www.jianshu.com/p/b70ff4ffb4fc

    3.自动执行postman的脚本:
    路径是绝对路径,文件是.bat,下面的脚本里改一下脚本的路径和环境变量的路径就OK了

    newman run D:\demoTest\xiApi.postman_collection.json --environment D:\demoTest\xiIP.postman_environment.json --globals D:\demoTest\**globals**.postman_globals.json --iteration-count 1 --disable-unicode --suppress-exit-code --ignore-redirects --bail --reporters cli,html,json,junit --reporter-html-export D:\demoTest\result.html
    

    上面的格式如果想一次性看清楚,那就看下面的这段代码,我为了方便各位,非脚本格式的也贴出来了

    newman run D:\demoTest\xiApi.postman_collection.json --environment D:\demoTest\xiIP.postman_environment.json --globals D:\demoTest*globals*.postman_globals.json --iteration-count 1 --disable-unicode --suppress-exit-code --ignore-redirects --bail --reporters cli,html,json,junit --reporter-html-export D:\demoTest\result.html

    努力就对了!

    相关文章

      网友评论

          本文标题:(转载)编写自动执行postman的脚本

          本文链接:https://www.haomeiwen.com/subject/thcnthtx.html