我正在使用 newman api 运行邮递员测试服。它按预期正确执行,但我想在文件中导出测试执行期间生成的环境变量,在命令行中可以使用--export-environment:
newman run collectionPreReq.json -e Environment.json -k --export-environment newmanExport.json
同样,我正在编写 javascript 以获取由 collectionPreReq 导出的环境,但没有得到我正在寻找的东西,代码是
var newman = require('newman');
newman.run({
collection: require('./collectionPreReq.json'),
//reporters: 'cli',
environment: require('./Environment.json'),
insecure: true
}).on('start', function (err, args) {
console.log('running a collection...');
}).on('done', function (err, summary) {
if (err || summary.error) {
console.error('collection run encountered an error.');
}
else {
console.log('collection run completed.:');
console.log("summary environment :");
console.log(summary.environment);
}
});
输出:
running a collection...
collection run completed.:
summary environment :
{ object: [Function], toJSON: [Function] }