我刚开始使用cucumberJs,gulp和量角器为一个角度的应用程序,并注意到,幸运的是,我的所有步骤都过去了,如果你不通过并在步骤定义中使用'callback'参数,cucumberJs可能不会知道,当该步骤完成,并且将跳过的其它步骤和它们所有标记为“通过”CucumberJs跳过步骤定义 - 也许回调步骤定义中的最后一个参数?
下面是从cucumberJs文档的一个示例:https://github.com/cucumber/cucumber-js
实施例1:
this.Given(/^I am on the Cucumber.js GitHub repository$/, function (callback) {
// Express the regexp above with the code you wish you had.
// `this` is set to a World instance.
// i.e. you may use this.browser to execute the step:
this.visit('https://github.com/cucumber/cucumber-js', callback);
//
的回调是通过编辑访问()这样,当作业的完成,该 下一步可以 //黄瓜
执行。 });
实施例2:
this.When(/^I go to the README file$/, function (callback) {
// Express the regexp above with the code you wish you had.
呼叫回调()结尾 //的步骤中,或回调(NULL, '等待处理'),如果步骤尚未实现:
callback(null, 'pending');
});
实施例3:
this.Then(/^I should see "(.*)" as the page title$/, function (title, callback) {
// matching groups are passed as parameters to the step definition
var pageTitle = this.browser.text('title');
if (title === pageTitle) {
callback();
} else {
callback(new Error("Expected to be on page with title " + title));
}
});
};
我知道你在这里有两个选择: a。 b。您要么退回承诺,不要将电话转回或b。您传递回调参数,并在步骤定义完成后调用它,以便cucumberJs知道要返回并转到下一步或下一个场景。
但是,我尝试了上述两种方法,仍然遇到了一个奇怪的情况,前两种情况按照您的预期正常工作,但同一功能文件中的第三种和第四种情况将被忽略并全部通过。
有什么特别的要考虑超过2场景的功能? 只要我有每个功能文件的< = 2场景,一切正常,但是当我有第三个场景时,该第三个场景被忽略并跳过。
任何想法?
嗨findlayc,是的,这是奇怪的事情,改变场景的工作顺序,而不改变实际场景 - 场景中没有语法错误,否则相同的场景将不会仅仅通过重新排列顺序。 – pelican
听起来像是一个异步问题 – findlayc