newman api

Newman是Postman提供的一个命令行工具,用于执行Postman集合。`newman.run()`方法接收一个包含集合运行详细信息的对象作为参数,如集合路径、环境变量、全局变量、迭代次数等。它还支持设置超时、延迟请求、忽略重定向和SSL校验等选项。运行完成后,会通过回调函数返回错误和总结信息,包括请求、预请求脚本、测试的执行详情和统计信息。
摘要由CSDN通过智能技术生成

1、run

其定义为

newman.run(options:object, callback:function) =>run:EventEmitter

参数详解

options必须的参数,类型为object,包含运行集合的所有信息
options.collection必须参数。接受postman 集合表示法。作为字符串,可以提供包含json集合的url或者本地json文件路径名
options.environment

接受字符串作为环境文件路径名或者url,用于读取postman环境变量。也可以接受object类型作为环境 变量。

可选 

类型object|string

options.envVar

key-value对象组成的数组作为环境 变量。

可选 

类型array|object

options.globals

全局变量。可以是文件名或者url,也可以是对象类型的变量

可选 

类型为object|string

options.globalVar

全局环境变量,是key-value对象的数组

可选 

类型为array|object

options.iterationCount

迭代次数。默认是1

可选 。

类型为number

options.iterationData

json或者csv文件或者url路径。

可选 

类型为string

options.folder

集合中的组名或者id。

可选 

类型为string|array

options.workingDir

工作目录路径 

可选 

类型为string,默认是Current Directory

options.insecureFileRead

允许读取工作目录外的文件 

可选 

类型为boolean,默认是true

options.timeout

等待集合执行完的时间 。

可选 

类型为number,默认是Infinity

options.timeoutRequest

指定等待请求返回响应的超时时间 

可选 

类型是number,默认是Infinity

options.timeoutScript

指定脚本返回响应的超时时间 

可选

 类型是number,默认是Infinity

options.delayRequest

指定相邻连续请求的间隔时间 。

可选 

类型是number,默认是0

options.ignoreRedirects

指定newman是否自动跟随3xx响应。

可选 

类型是boolean,默认是false

options.insecure

禁止ssl校验检查,允许自签名证书

可选 

类型为boolean,默认是false

options.bail

指定当遇到第一个错误时是否优雅停止集合运行的开关。携带另外的修饰符作为参数指定当遇到错误或者错误的路径名是否结束运行

可用的修改符有:folder,failure

可选 

类型为boolean|object,默认是false

options.suppressExitCode

是否允许覆盖默认的退出码。

可选 

类型为boolean,默认是false

options.reporters

字符串时是指定上报者类型,数组时是指定多个上报者

可用的上报者有:cli,json,junit,progress和emojitrain

可选 

类型为string|array

options.reporter

为options.reporters中的上报者指定选项。

比如:reporter : { junit : { export : './xmlResults.xml' } }或者reporter : { html : { export : './htmlResults.html', template: './customTemplate.hbs' } }

可选 

类型为object

options.color

彩色cli输出开关

可用的值有:on,off和auto

可选 

类型为string,默认是auto

options.sslClientCert

证书文件路径 

可选 

类型为string

options.sslClientKey

密钥文件路径 

可选 

类型为string

options.sslClientPassphrase

密钥客户端密钥密码短语

可选 

类型为string

options.sslClientCertList

证书列表 文件 路径 

可选 

类型为string|array

options.requestAgents

指定分别执行HTTP和HTTPS请求时要使用的自定义请求代理

可选 

类型为object

options.cookieJar

可以选择将CookieJar文件路径作为字符串传递给此属性,并使用硬cookie进行反序列化。此属性还接受一个cookie CookieJar实例

可选 

类型为object|string

options.newmanVersion

newman的版本号

由newman来设置

callback

运行完成后,将使用error,summary参数执行此回调

必选项

类型为function

callback(error: object , summary: object)

ArgumentDescription
errorIn case newman faces an error during the run, the error is passed on to this argument of callback. By default, only fatal errors, such as the ones caused by any fault inside Newman is passed on to this argument. However, setting abortOnError:true or abortOnFailure:true as part of run options will cause newman to treat collection script syntax errors and test failures as fatal errors and be passed down here while stopping the run abruptly at that point.

Type: object
summaryThe run summary will contain information pertaining to the run.

Type: object
summary.errorAn error object which if exists, contains an error message describing the message

Type: object
summary.collectionThis object contains information about the collection being run, it's requests, and their associated pre-request scripts and tests.

Type: object
summary.environmentAn object with environment variables used for the current run, and the usage status for each of those variables.

Type: object
summary.globalsThis object holds details about the globals used within the collection run namespace.

Type: object
summary.runA cumulative run summary object that provides information on .

Type: object
summary.run.statsAn object which provides details about the total, failed, and pending counts for pre request scripts, tests, assertions, requests, and more.

Type: object
summary.run.failuresAn array of failure objects, with each element holding details, including the assertion that failed, and the request.

Type: array.<object>
summary.run.executionsThis object contains information about each request, along with it's associated activities within the scope of the current collection run.

Type: array.<object>

参考资料:

https://github.com/postmanlabs/newman

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kgduu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值