1

自動化されたテスト スイートを構築するために、 CucumberJSchai-as-promised (CucumberJS にはアサーション ライブラリが組み込まれていないため) でProtractorを使用しています。

単一のアサーションに対してはすべて正常に機能します (chai-as-promisedのexpect機能を使用)。ただし、同じテスト (ステップ) 内で複数の promise を処理しようとすると、問題が発生します。次の例では、verifyUserFirstName は、特定の行の td.getText() にマップされた promise を返します。

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() だけを特徴とするステップが失敗した場合 (以下の例を参照)、すべてが完全に機能します。失敗したステップとして記録され、分度器は残りのテストを完了まで実行し続けます。誰もこれを経験しましたか?

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);
});
4

1 に答える 1

1

私は同じ課題を抱えていましたが、これが私が解決した方法です:

this.Then(/^I should see my user entry with proper values in the list$/, function (callback) {
    var verifyUser = Q.all([
        usersPage.verifyUserFirstName('tony@gmail.com'),
        usersPage.verifyUserLastName('tony@gmail.com'),
        usersPage.verifyUserPhone('tony@gmail.com')
    ]);
    expect(verifyUser).to.eventually.deep.equal(['Tony', 'Bui', '8764309111').and.notify(callback);
}

それが役立つことを願っています!

于 2015-05-07T15:30:31.037 に答える