UndefinedDataTableTypeException with Boolean
gaeljw opened this issue ยท 2 comments
๐ What did you see?
Cucumber is not able to convert DataTable to Map<String, Boolean>.
It fails with following error:
io.cucumber.datatable.UndefinedDataTableTypeException: Can't convert DataTable to Map<java.lang.String, java.lang.Boolean>.
[error] Please review these problems:
[error]
[error] - There was no table entry transformer registered for java.lang.Boolean.
[error] Please consider registering a table entry transformer.
[error]
[error] - There was no table cell transformer registered for java.lang.Boolean.
[error] Please consider registering a table cell transformer.
[error]
[error] - There was no default table cell transformer registered to transform java.lang.Boolean.
[error] Please consider registering a default table cell transformer.
[error]
โ
What did you expect to see?
To be honest, I'm not sure I personally expect Cucumber to handle this case. But I admit it would be nice to handle conversion to Boolean as other types are handled like String or Integer for instance.
๐ฆ Which tool/library version are you using?
Cucumber Core 7.7.0.
๐ฌ How could we reproduce it?
Scenario: As Map of boolean
Given the following table as Scala Map with boolean
| row1 | true |
| row2 | |
| row3 | false |@Given("the following table as Scala Map with boolean")
public void my_step(DataTable table) {
Map<String, Boolean> data = table.asMap(String.class, Boolean.class)
Map<String, Boolean> expected = Map.ofEntries(
entry("row1", Boolean.TRUE)
entry("row2", null),
entry("row3", Boolean.FALSE)
)
assert(data == expected)
}๐ Any additional context?
The issue was actually raised on Scala implementation in the first place: cucumber/cucumber-jvm-scala#322
If you point me in the right direction, I could probably open a PR to fix it.
I didn't search much yet so I might be saying toal nonsense but would this relate to the types defined at
?Yeah. That's the right spot. Not sure why I never added booleans. Note that they should be replaceable to facilitate converters that work with other boolean strings like yes/no ect. That's what the true flag is for IIRC.