postman+newman+jenkins

1.新建

2.选择get请求,输入一个url。这里用一个心知天气https://docs.seniverse.com/api/weather/now.html,获取API接口文档,根据接口文档设置参数

https://api.seniverse.com/v3/weather/now.json这里只需要到json这里

 

 

 

 

3.添加断言

 

4. 导出json文件,导出之前一定保存get请求的url数据

 

6.安装使用newman

6.1安装node,并配置环境变量

  64 位安装包下载地址 : https://nodejs.org/dist/v10.16.1/node-v10.16.1-x64.msi

 

6.2安装Newman

  node需要在6版本以上

6.3使用Newman

newman run 文件.json

 

7.指定生成报告

通过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

在使用时可能会因为工具没有安装而报错,可以使用命令安装:npm install newman-reporter-html

 

8.结合Jenkins使用

平时做接口自动化,避免不了最后通过Jenkins做构建。既然Newman提供了控制台命令执行方式,那么像通过Jenkins来构建也就容易多了。
步骤一:在Jenkins 机器上安装Newman
步骤二:搭建Jenkins环境,并新建个自由风格的Job
步骤三:构建选择Execute Windows batch command,并输入newman 运行命令

步骤四:因为上面命令中构建会生成junit的xml报告,所以可以在构建后用Publish JUnit test result report 插件来生成测试报告。

 

 

posted @ 2019-08-01 17:01  Gxx0_0  阅读(268)  评论(0编辑  收藏  举报