【发布时间】:2016-09-09 17:56:46
【问题描述】:
我将 Protractor 与 CucumberJS 和 chai-as-promised 一起使用(因为 CucumberJS 没有内置的断言库)构建自动化测试套件。
对于单个断言来说一切正常(使用 chai-as-promised 的 expect 特性)。但是,当尝试在同一个测试(步骤)中处理多个承诺时,我遇到了麻烦。在以下示例中,verifyUserFirstName 返回一个映射到特定行的 td.getText() 的承诺。
this.Then(/^I should see my user entry with proper values in the list$/, function (callback) {
expect(usersPage.verifyUserFirstName('tony@gmail.com')).to.eventually.equal('Tony');
expect(usersPage.verifyUserLastName('tony@gmail.com')).to.eventually.equal('Bui');
expect(usersPage.verifyUserPhone('tony@gmail.com')).to.eventually.equal('8764309111');
callback();
目前,当任何 expect() 行失败时,Protractor 将退出并让浏览器窗口挂起,而不运行其余测试。
当仅包含一个 expect() 的步骤失败时(参见下面的示例),一切正常。它被记录为失败的步骤,并且 Protractor 继续运行其余的测试以完成。有人经历过吗?
this.Then(/^I should be directed to the user list page$/, function (callback) {
expect(browser.getCurrentUrl()).to.eventually.equal('http://localhost:9001/#/nav/').and.notify(callback);
});
【问题讨论】:
标签: javascript angularjs cucumber protractor chai-as-promised