我正在尝试使用 jbehave 扩展创建一个带有宁静(前修昔底德)的 BDD 测试,这是我的故事(源自宁静的 jbehave 示例)
Scenario: a scenario with embedded tables
Given that I sell the following fruit
| fruit | price |
| apples | 5.00 |
| pears | 6.00 |
And I sell the following vegetables
| vegetable | price |
| potatoe | 4.00 |
| carrot | 5.50 |
When I sell fruit
Then the total cost should be total
Examples:
| goods | total |
| apples, carrot | 11.50 |
| apples, pears | 11.00 |
| potatoe, carrot | 9.50 |
生成的java代码如下:
@Given("that I sell the following fruit\r\n| fruit | price |\r\n| apples | 5.00 |\r\n| pears | 6.00 |")
public void givenThatISellTheFollowingFruitFruitPriceApples500Pears600() {
// PENDING
}
@Given("I sell the following vegetables\r\n| vegetable | price |\r\n| potatoe | 4.00 |\r\n| carrot | 5.50 |")
public void givenISellTheFollowingVegetablesVegetablePricePotatoe400Carrot550() {
// PENDING
}
@When("I sell fruit")
public void whenISellFruit() {
}
@Then("the total cost should be total")
public void thenTheTotalCostShouldBeTotal() {
// PENDING
}
如何在我的测试中检索表参数?
我试过了ExamplesTable
按照关于 jbehave 表格参数的文档尝试了参数,但没有奏效。
有没有办法使given
注释更具可读性(通过不添加表参数)?