接口测试

Postman--newman

2017-11-07  本文已影响0人  Cassie测试路

1. newman 命令行方式运行Collection

# 安装 newman
npm install -g newman
newman --version           # 3.5.2
npm update -g newman       # 升级到最新的版本3.8.3


# newman命令行运行导出的collection.json或者collection link
newman run OpenAPI-User.postman_collection.json -e gitee.com.postman_environment.json

# -e <source> --environment, Specify an environment file path or URL 指定测试环境

# --global-var  指定全局变量,可以指定多个例如:--global-var "key1=value1" --global-var "key2=value2"

2. Using Newman as a NodeJS module

var newman = require('newman');     //加载newman模块
 
// call newman.run to pass `options` object and wait for callback
// options对象,由很多属性键值对组成
newman.run({
    collection: require('./sample-collection.json'), // 加载Colllection文件
    reporters: 'cli',     // Available reporters: cli, json, html and junit. 指定输出方式
    environment: require('./gitee.com.postman_environment.json'), //加载环境文件
    globals: require('./globals.postman_globals.json'),   //加载全局变量文件
    iterationCount: 1  //重复次数,默认1
}, function (err) {
    if (err) { throw err; }
    console.log('collection run complete!');  // 始终输出此结束语
});
上一篇 下一篇

猜你喜欢

热点阅读