question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataTable - Automatic conversion to custom type stopped working

See original GitHub issue

Summary

After updating cucumber-testng (and subsequently all transient dependencies) from 2.4.0 to 3.0.2 in pom.xml, automatic conversion for datatables using custom types stopped working and now throws UndefinedDataTableTypeException.

Expected Behavior

Only change required is to update imports to import io.cucumber.datatable.DataTable; and tests to run as per usual.

Current Behavior

Getting this exception from steps that worked prior to update:

io.cucumber.datatable.UndefinedDataTableTypeException: Can’t convert DataTable to List<jcucumberng.steps.pojos.Income>. Please register a DataTableType with a TableEntryTransformer or TableRowTransformer for class jcucumberng.steps.pojos.Income

// Feature
When I Enter My Regular Income Sources
  | name   | amount | frequency     |
  | Salary | 25000  | every 2 weeks |


// Stepdef
@When("^I Enter My Regular Income Sources$")
public void I_Enter_My_Regular_Income_Sources(DataTable dataTable) throws Throwable {
    List<Income> incomes = dataTable.asList(Income.class);

    // More code    
}


// Custom type
public class Income {

    private String name = null;
    private String amount = null;
    private String frequency = null;

    public Income(String name, String amount, String frequency) {
        this.name = name;
        this.amount = amount;
        this.frequency = frequency;
    }

    // Getters and setters
}

Possible Solution

Show more useful comments/javadocs for DataTable specially if updating from v2.x.x to v3.x.x for major changes to its usage. Allow easier automatic conversion like before.

Context & Motivation

A revamp of the DataTable usage will break a lot of existing tests and can totally prevent people from updating to v3.x.x. It also outdates a lot of widely available tutorials and references.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:39 (31 by maintainers)

github_iconTop GitHub Comments

3reactions
aslakhellesoycommented, Jun 9, 2018

I’ve got a pending PR for this (haven’t pushed yet). I’m reopening since I plan to fix it next week.

Context: I just ran a public training where a few people remarked that while the new data tables are great, they do require more boilerplate/configuration code. I think I’ve found a pragmatic middle ground, where you’ll still need to register a DataTableType, but doing so will be a one-liner.

1reaction
mpkorstanjecommented, Jul 12, 2022

You are looking for a quick fix for what exactly? The context of this issue allows for a number of problems.

To wit the default table converters receive the same information that XStream would. So if anything you can use XStream as the default converter though you may have to copy the exact configuration from Cucumbers v2.4 source to retain all features and functionality.

You can find documentation here, though I’d suggest reading the context around it too:

Do bear in mind that this is an open source project, developed primarily by volunteers and available free of charge. While it is unfortunate that you are working with professional constraints and requirements that put you in a bind they are yours to solve.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cucumber 6.9 java8, cannot convert from DataTable to custom ...
I want to register my custom type in order to automatically get a list from datatable. Despite there are many sources refering to ......
Read more >
DataTable - Automatic conversion to custom type stopped working
After updating cucumber-testng (and subsequently all transient dependencies) from 2.4.0 to 3.0.2 in pom.xml , automatic conversion for datatables using custom ...
Read more >
Using data table types in Cucumber-JVM - On Test Automation
Enter the data table type, accessed through the @DataTableType annotation. ... method body does not change, empty string conversion happens automatically }.
Read more >
Convert the data type of column of datatable - UiPath Forum
I am using Read Range Activity and the data table automatically picks a column type as double which is having both number and...
Read more >
lightning-datatable - documentation - Salesforce Developers
Working with Column Properties. Use the following column properties to customize the behavior and visual aspects of your columns. Property, Type, Description ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found