2016-03-02 136 views
0
// signin.test.js 
... 
this.Then(/^I should be redirected to my dashboard$/, function() { 
    var self = this; 
    return this.browser 
    .getUrl().then(function(eUrl) { 
     eUrl.should.be.equal(self.url); 
    }) 
    .end(); 
}); 
... 

而這與註冊功能完全相同。對具有相同步驟定義的cucumberjs執行不同功能時出錯

// signup.test.js 
... 
this.Then(/^I should be redirected to my dashboard$/, function() { 
    var self = this; 
    return this.browser 
    .getUrl().then(function(eUrl) { 
     eUrl.should.be.equal(self.url); 
    }) 
    .end(); 
}); 
... 

運行測試,我得到這個錯誤sign-in功能:

enter image description here

然而,測試將正常運行,如果我

  • 選項1:註釋掉以上js signin.test.js或signup.test.js的一部分。
  • 選項2:將描述更改爲另一個文本以使其不同,例如I should be redirected to my dashboard 12345

這是一個缺陷cucumberjs

反正有辦法解決這個問題。

回答

0

您確定該錯誤指示了未定義的步驟定義嗎?它似乎更可能報告一個含糊不清的步驟定義。作爲v0.9.0ambiguous step definitions are no longer allowed

0.9.0 

Breaking changes 

* catch ambiguous step definitions (Charlie Rudolph) 
* remove use of domain (Charlie Rudolph) 

在任何情況下,執行的代碼相同的塊是一個壞習慣,你應該儘量避免。請參閱DRY Principle。我建議你採用選項1並完全刪除重複的步驟定義。

相關問題