Skip to content

Commit 01932dc

Browse files
committed
Added an example of how to convert a DataTable to a List of Thing in Groovy
1 parent 97f14d5 commit 01932dc

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

groovy/src/test/groovy/cucumber/runtime/groovy/compiled_stepdefs.groovy

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ Given(~'^I have (\\d+) apples in my belly') { int apples ->
1616
Given(~'^a big basket with cukes') {->
1717
}
1818

19+
Given(~'^the following table:$') { table ->
20+
things = table.asList(Thing)
21+
assertEquals("Cucumber-JVM", things[1].name)
22+
}
23+
24+
class Thing {
25+
Integer year
26+
String name
27+
}
28+
1929
Then(~'^there are (\\d+) cukes in my belly') { int cukes ->
2030
checkCukes(cukes)
2131
}

groovy/src/test/resources/cucumber/runtime/groovy/a_feature.feature

+7
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ Feature: Cucumber Runner Rocks
1515
| n | what | mood |
1616
| 13 | cukes | happy |
1717
| 4 | apples | tired |
18+
19+
@focus
20+
Scenario: a table
21+
Given the following table:
22+
| year | name |
23+
| 2008 | Cucumber |
24+
| 2012 | Cucumber-JVM |

groovy/src/test/resources/cucumber/runtime/groovy/interpreted_stepdefs.groovy

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ Given(~'^I have (\\d+) cukes in my belly') { int cukes ->
77
haveCukes(cukes)
88
lastAte('cukes')
99
}
10-

0 commit comments

Comments
 (0)