0
点赞
收藏
分享

微信扫一扫

Newman定制报告



定制报告

  • ​​一、前言​​
  • ​​二、构建定制报告​​
  • ​​三、使用自定义的报告​​
  • ​​四、CLI​​

一、前言

如果想根据特定请求生成报告,定制报告就会派上用场,例如,在请求(或测试)失败时、输出响应主体日志时。

二、构建定制报告

定制报告是一个节点模块,其名称为newman-reporter-。创建一个定制报告的步骤如下。

1)定制报告是一个节点模块,其使用npm init创建一个空白的npm包。

2)添加一个index.js文件,导出如下形式的函数。

Newman定制报告_包名

3)使用npm发布报告,或者在本地使用报告。另外,也支持如@myory/newman-reporter-所示的报告名称。

三、使用自定义的报告

为了使用自定义报告。必须安装对应的报告包。例如:使用Newman teamcity reporter的方法如下。

1)安装reporter包。


npm install newman-reporter-teamcity


请注意,包的名称为newman -reporter-,其中是reporter的实际名称。如果Postman是全局安装的,则这个包也应该全局安装。运行npm install<包名>,使用“-g”标志进行全局安装。

2)要是用本地(非公开)的报告,请运行命令npm install <path/to/local-reporter-directory>。

3)通过CLL或Programmatically使用已安装的报告。在这里,在选项中指定报告名称时不需要newman -reporter前缀。

4)作用域的报告必须使用范围前缀来指定。例如,如果包名是@myory/newman-reporter-,必须使用@myory/ name指定报告。

四、CLI

具体命令如下。

newman run  /patn/to/collection.JSON -r myreporter --reporter-myreporter-
<option-name> <option-value> #the option is optional

Programmatically:
var newman = require('newman');

newman.run({
collection: '/patn/to/collection.JSON'
reporters: 'myreporter'
reporter: {
myreporter: {
'option-name': 'option-value' //the option is optional
}
}
},function (err,summary){
if (err) {throw err;}
console.info('collection run complete!');
});


举报

相关推荐

0 条评论