java - BDD: Embedded tables with serenity and jbehave -


i'm trying create bdd test serenity (former thucydides) using jbehave extension, story (originating serenity jbehave examples)

scenario: scenario embedded tables given sell following fruit | fruit  | price | | apples | 5.00  | | pears  | 6.00  | , sell following vegetables | vegetable | price | | potatoe   | 4.00  | | carrot    | 5.50  | when sell fruit total cost should total examples: | goods           | total | | apples, carrot  | 11.50 | | apples, pears   | 11.00 | | potatoe, carrot | 9.50 | 

the generated java code following:

@given("that sell following fruit\r\n| fruit  | price |\r\n| apples | 5.00  |\r\n| pears  | 6.00  |") public void giventhatisellthefollowingfruitfruitpriceapples500pears600() {     // pending }  @given("i sell 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 total") public void thenthetotalcostshouldbetotal() {     // pending } 

how retrieve table arguments in test ?

i tried examplestable parameters per documentation on jbehave tabular parameters did not work.

is there way make given annotation more readable (by not adding table parameters) ?

you can retrieve exampletable parameter (and have more readable given annotations):

@given("that sell following fruit $exampletable") public void thatisellthefollowingfruit(examplestable exampletable) {     system.out.println("mytable: "+exampletable.asstring()); } 

if doesn't find declared method , tells step pending, check if have whitespace in story after word fruit:

given sell following fruit  

how access several rows , columns in tables written in jbehave documentation under http://jbehave.org/reference/stable/tabular-parameters.html

you think creating 1 table instead of three:

scenario: scenario embedded tables given sell <product1>  , price <product1price> , sell <product2>  , price <product2price> when sell total cost should <total> examples: | product1 | product1price | product2 | product2price | total | | apples   | 5.00          | carrot   | 6.50          | 11.50 | | apples   | 5.00          | pears    | 6.00          | 11.00 | | potatoe  | 4.00          | carrot   | 9.50          | 13.50 

the java code have access parameters:

@given("i sell <product1>") public void isellproduct(@named("product1") string product1) {     //do product1 } 

does help? if not, not work when try read exampletable?


Comments