有没有办法在先前场景中的步骤失败后继续执行测试场景?
Is there a way to continue test scenario execution after step failure in a previous scenario?
每当在远程服务器上 运行 时出现步骤失败,我想捕获失败的步骤,然后继续 运行 剩余的场景。然后,捕获的步骤将包含在文件中以用于报告目的。有这种可能吗?我在其他地方看到的所有回复都只是说你应该在继续之前修复测试。我同意,但我只希望测试在本地 运行 时停止,而不是远程。
➜ customer git:(pat104) ✗ cucumber.js -f progress (pat104⚡)
...F-----Failed scenario: View and select first contact from contact history
...F-Failed scenario: View and select a contact from multiple contacts in history
..................................................F---Failed scenario: Navigating to profile with url and enrollmentId
...................................................F-Failed scenario: Successful MDN Search with 1 result returned. Tech Selects and continues
.............FFailed scenario: Successful MDN with multiple results
这是默认行为,不是吗?示例命令
cucumber.js -f json > cucumberOutput.json
好吧,您需要使用 callback.fail(e)
在您的测试中进行管理,如下所示。您可以使用 grunt-cucumberjs 之类的库将这些错误添加到漂亮的 HTML 报告中。
this.Then(/^the save to wallet button reflects the offer is saved$/, function (callback) {
merchantPage(this.nemo).doStuff().then(function () {
callback();
}, function (e) {
callback.fail(e); //add this to report
});
});
或者您可以使用 Hooks 并检查场景是否失败并报告(截图或添加日志记录等)
this.After(function (scenario, callback) {
var driver = this.nemo.driver;
if(scenario.isFailed()){
driver.takeScreenshot().then(function (buffer) {
scenario.attach(new Buffer(buffer, 'base64').toString('binary'), 'image/png');
});
}
driver.quit().then(function () {
callback();
});
});
事实证明,其中一个步骤定义错误地使用了 .waitForExist。测试写成:
this.browser
.waitForExist('#someElement', 1000, callback)
回调不是 .waitForExist 的参数,重写为:
.waitForExist('#someElement',1000).then(function (exists) {
assert.equal(exists, true, callback);
})
每当在远程服务器上 运行 时出现步骤失败,我想捕获失败的步骤,然后继续 运行 剩余的场景。然后,捕获的步骤将包含在文件中以用于报告目的。有这种可能吗?我在其他地方看到的所有回复都只是说你应该在继续之前修复测试。我同意,但我只希望测试在本地 运行 时停止,而不是远程。
➜ customer git:(pat104) ✗ cucumber.js -f progress (pat104⚡)
...F-----Failed scenario: View and select first contact from contact history
...F-Failed scenario: View and select a contact from multiple contacts in history
..................................................F---Failed scenario: Navigating to profile with url and enrollmentId
...................................................F-Failed scenario: Successful MDN Search with 1 result returned. Tech Selects and continues
.............FFailed scenario: Successful MDN with multiple results
这是默认行为,不是吗?示例命令
cucumber.js -f json > cucumberOutput.json
好吧,您需要使用 callback.fail(e)
在您的测试中进行管理,如下所示。您可以使用 grunt-cucumberjs 之类的库将这些错误添加到漂亮的 HTML 报告中。
this.Then(/^the save to wallet button reflects the offer is saved$/, function (callback) {
merchantPage(this.nemo).doStuff().then(function () {
callback();
}, function (e) {
callback.fail(e); //add this to report
});
});
或者您可以使用 Hooks 并检查场景是否失败并报告(截图或添加日志记录等)
this.After(function (scenario, callback) {
var driver = this.nemo.driver;
if(scenario.isFailed()){
driver.takeScreenshot().then(function (buffer) {
scenario.attach(new Buffer(buffer, 'base64').toString('binary'), 'image/png');
});
}
driver.quit().then(function () {
callback();
});
});
事实证明,其中一个步骤定义错误地使用了 .waitForExist。测试写成:
this.browser
.waitForExist('#someElement', 1000, callback)
回调不是 .waitForExist 的参数,重写为:
.waitForExist('#someElement',1000).then(function (exists) {
assert.equal(exists, true, callback);
})