2012-01-04 90 views
6

我正在使用Jbehave作爲我的BDD框架。我正在尋找一種方式來自動生成文本場景候選人步法存根像自動生成JBehave中的stext場景的候選步驟方法存根

Given there is a flight 
And there is a customer 
When the customer books the flight 
Then the customer is shown on the manifest 

到Java這樣的:

<@> Given("there is a flight") 
<[email protected]> Pending 
public void thereIsAFlight() { 
} 

<@> Given("there is a customer") // note 'Given', even though story line is 'And' 
<@> Pending 
public void thereIsACustomer() { 
} 

<@> When("the customer books the flight") 
<@> Pending 
public void theCustomerBooksTheFlight() { 
} 

<@> Then("the customer is shown on the flight manifest") 
<@> Pending 
public void thenTheCustomerIsShownOnTheFlightManifest() { 
} 

不JBehave提供它作爲一個隱含的功能,或者人們使用一些IDE插入 ?我將非常感謝這裏的任何幫助。

回答

5

當您運行JBehave時,它會跟蹤尚未找到匹配綁定代碼的所有步驟,並轉儲相應的存根實現,這與您所寫的內容非常相似。 此輸出可在控制檯上使用,但也可在HTML報告中使用(如果您打開了它們)。 將它們複製並放入步驟課程中。

如果您要求讓JBehave自動將存根實現寫入到.java文件中,那麼我非常懷疑存在這樣一個功能 - 很難知道要使用哪個文件類&。 (下一頁到SCM的整合問題,等等。)

+1

這個特性存在於cucumber-jvm中。由於缺乏對應該成爲任何黃金標準bdd測試引擎一部分的功能的支持,我正在考慮切換引擎。 – Ajax 2016-04-10 00:27:20