Я пытаюсь создать тест BDD с безмятежностью (бывший Фукидид), используя JBehave расширения, это моя история (происходящая из безмятежности 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
более читаемым (не добавляя параметры таблицы)?
Я попробовал несколько способов ввода '$ exampleTable' в мой метод, но я думаю, что я использовал' 'и не удалял конец сгенерированного имени метода (... FruitPriceApples500Pears600) –
phury
Я хотел первый пример для работы, потому что я использую json в своих табличных данных и ввод нескольких json-объектов в строке на самом деле не читается – phury