How to represent List<String> in a feature file in a Cucumber feature file datatable

51 views Asked by At

I am unable to represent List<String> in the cucumber datatable in my feature file.

I'm updating a step in a feature file where in that step I simply convert the Cucumber DataTable to List<ObjectB> using .asList(ObjectB.class) provided by the cucumber DataTable class. For each row of the DataTable, every field is correctly mapped but the new one being added (list) is is just getting mapped as null and I cannot figure out how to properly represent this in the datatable in the feature file to stop it getting mapped as null.

From the fields below in the feature file table, the key and time fields get mapped properly but the list field always gets mapped as null when I expect it to be converted to a Java List<Sring>:

Given I create a list of objects:
|  key   |        time          |        list            |
| <key1> | 2022-04-28T00:00:00Z | ["string1", "string2"] |
| <key2> | 2022-05-28T00:00:00Z | ["string3", "string4"] |

Step definition:

Given("I create a list of objects:", (DataTable dataTable) -> {
    List<ObjectB> objectsList = dataTable.asList(ObjectB.class);
});

Class definition for ObjectB:

@Data
@SuperBuilder
public class ObjectB extends ObjectA {
  private final Instant time;
}

Class definition for ObjectA:

@Data
@SuperBuilder
public class ObjectA {
  private final UUID key;
  private final List<String> list;
}
0

There are 0 answers