纽曼-在每个测试脚本/测试用例之前运行特定操作

时间:2018-10-16 09:40:54

标签: postman newman postman-collection-runner

我当前正在使用newman作为我的跑步者,并且我有这个javascript文件,该文件处理了在执行过程中触发的一系列事件。

我正在执行从邮递员导出的收藏集。我遇到一个问题,其中我使用了一个事件“ beforeTest”,该事件希望在每个测试脚本(邮递员的子文件夹)之前运行,但是发生的事情是它在每个http请求之前运行。

这是我的js文件运行程序中的示例代码。

newman.run({
    collection: "myCollection.json",
    environment:  "myEnvironment.json",
    globals: "",
    reporters: ['json','html','cli'],
    reporter: {}
}).on('beforeTest', function (err, args) { //before test run
    //Run some code here
    //Expected: Since I used 'beforeTest' I expect that this code will be triggered before each testscript
    //Actual: This code was triggered before each http request
}).on('start', function (err, args) { // on start of run, log to console
    //Run Testscript here
}).on('done', function (err, summary) {
    //Run some code here
});

有没有一种方法可以使事件“ beforeTest”仅在每个测试脚本之前运行?我错过了什么还是做错了什么?感谢您的帮助!

0 个答案:

没有答案