@@ -22,26 +22,31 @@ Add the `datatable-matchers` dependency to your pom.
22
22
Use the matcher in your step definition.
23
23
24
24
``` java
25
- import static io.cucumber.datatable.matchers.DataTableHasTheSameRowsAs.hasTheSameRowsAs ;
25
+ import io.cucumber.datatable.DataTable ;
26
+ import io.cucumber.java.en.Then ;
26
27
27
- [... ]
28
-
29
- private final DataTable expected = DataTable . create(
30
- asList(
31
- asList(" Annie M. G." , " Schmidt" ),
32
- asList(" Roald" , " Dahl" ),
33
- ));
34
-
35
- @Then (" these authors have registered:" )
36
- public void these_authors_have_registered(DataTable registeredAuthors){
37
- assertThat(registeredAuthors, hasTheSameRowsAs(expected). inOrder());
38
-
39
- // java.lang.AssertionError:
40
- // Expected: a datable with the same rows
41
- // but: the tables were different
42
- // - | Annie M. G. | Schmidt |
43
- // | Roald | Dahl |
44
- // + | Astrid | Lindgren |
45
- }
28
+ import static io.cucumber.datatable.matchers.DataTableHasTheSameRowsAs.hasTheSameRowsAs ;
29
+ import static java.util.Arrays.asList ;
30
+ import static org.hamcrest.MatcherAssert.assertThat ;
31
+
32
+ public class StepDefinitions {
33
+
34
+ // Provided by the system under test
35
+ DataTable actual = DataTable . create(asList(
36
+ asList(" Annie M. G." , " Schmidt" ),
37
+ asList(" Roald" , " Dahl" )
38
+ ));
39
+
40
+ @Then (" these authors have registered:" )
41
+ public void these_authors_have_registered (DataTable expected ) {
42
+ assertThat(actual, hasTheSameRowsAs(expected). inOrder());
43
+ // java.lang.AssertionError:
44
+ // Expected: a datable with the same rows
45
+ // but: the tables were different
46
+ // + | Annie M. G. | Schmidt |
47
+ // | Roald | Dahl |
48
+ // - | Astrid | Lindgren |
49
+ }
50
+ }
46
51
```
47
52
0 commit comments