简体   繁体   中英

Caused by: io.cucumber.datatable.UndefinedDataTableTypeException: Can't convert DataTable to List

I am updating cucumber version from 3x to 7x and I faced following exception:

Caused by: io.cucumber.datatable.UndefinedDataTableTypeException: Can't convert DataTable to List

There was no table entry or table row transformer registered for com.x.config
   Please consider registering a table entry or row transformer.

and code is as follows:

    @And("^configurations$")
    public void configurations(List<Config> configs) {
        initialConfigs = configs.stream().map(cfg -> Config.builder()
}

I found how to solve it, by adding Transformer in step definition that should be as follows:

 @DataTableType
    public Config entryTransformer(Map<String, String> row) {

        return Config.builder()
                .id(Integer.parseInt(row.get("id")))
                .active(row.get("active"))
                .build();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM