2012-01-04 83 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