51Testing软件测试论坛

标题: 接口自动化-postman集成Jenkins [打印本页]

作者: Miss_love    时间: 2017-12-22 10:25
标题: 接口自动化-postman集成Jenkins
newman
Newman是Postman的一个命令行集合运行者。 它允许您直接从命令行运行和测试Postman集合。 它是以可扩展性为基础构建的,因此您可以轻松将其与持续集成服务器集成并构建系统。
官方简介:https://www.getpostman.com/docs/ ... gration_with_newman
通过npm安装,使用淘宝镜像。
命令:npm install -g newman --registry=https://registry.npm.taobao.org   
命令:newman run test.postman_collection.json(postman导出的文件名称)
注:分享URL需要先注册postman

运行命令:newman run https://www.getpostman.com/collections/77272ceeffb136b216a4
注意 :run 后面跟上要执行的json文件或者URL(json 和 URL 都由postman导出生成),后面可加上一些参数,例如环境变量,测试报告,接口请求超时时间等等。一下两个完整的例子做参考
例子1,通过newman 运行postman导出的test1.json文件,并生成多种测试报告(json,junit的xml,html):
newman run c:\test1.json --reporters cli,html,json,junit --reporter-json-export jsonOut.json --reporter-junit-export xmlOut.xml --reporter-html-export htmlOut.html
标红部分修改成需要生成的报告名称:newman run test.postman_collection.json --reporters cli,html  --reporter-html-export test.html  此例子中只生成了HTML报告
例子2,运行https://www.getpostman.com/collections/cb0cea0af1467c8008fb(postman生成的 )中的所有api,并使用env.json作为环境变量和globals.json作为全局变量,并使用外部data.csv作为外部数据,最后设置了接口请求超时时间为5S 。
newman run https://www.getpostman.com/collections/77272ceeffb136b216a4 --environment env.json --iteration-data data.csv --globals globals.json --timeout-request 5000
Jenkins集成

注意:生成HTML报告,将postman导出的用例放在Jenkins的workspace\{创建的job目录下}
如:\workspace\newman_test
构建后操作--设置  *.xml

生成的XML报告



作者: 黄粱一梦    时间: 2017-12-22 11:53
看不见图片啊  怎么还是原创的呢
作者: joykao    时间: 2017-12-22 14:53
怒顶一发
作者: Miss_love    时间: 2017-12-22 15:27
图片挂了,,后续有空补一下吧。。。
作者: 小小小提姆    时间: 2017-12-27 16:45
顶一个
作者: oucfanglei    时间: 2017-12-31 18:05
看不了图
作者: applepen    时间: 2018-2-11 10:28
感谢分享。
如果图能显示出来就更完美了。
作者: libingyu135    时间: 2018-4-25 17:41
图片都显示不了了
作者: 岛屿soliloquy    时间: 2018-7-20 14:24
图看不了,先留个名




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2