Support title case data table headers #1746
Labels
good first issue
Good for newcomers
🙏 help wanted
Help wanted - not prioritized by core team
⚡ enhancement
Request for new functionality
Milestone
Summary
When using Jackson as a default data table entry transformer it is possible to automatically convert data tables to lists of specific objects. Doing so however requires that headers are written in camel case. They must match the property names of the object.
Expected Behavior
When using Jacksons
ObjectMapper
as a default table entry converter then some data table with title case headers should be convertible to a list of authors.Current Behavior
Jackson will complain about
Workaround 1
Configure Jackson with a space case naming strategy.
A limitation of this strategy is that it converts property names to data table names.
This means that for a given property name there is exactly one correct data table
way of writing a data table header. Converting in the other direction like the cucumber
1/2.x implementation did, made writing headers in title case possible e.g:
Jackson:
Cucumber:
Workaround 2
Annotate the
Author
class withJsonProperty
and provide the header name. While surprisingly simple doesn't scale so well once many tables are involved. Can be combined with the first work around.Possible Solution
Add a field to the
@DefaultDataTableEntryTransformer
annotation. When this field is set (to some value t.b.d.) theJavaDefaultDataTableEntryTransformerDefinition
will convert the title case header names to camel case property names before passing them on to the annotated method.For a reference of the title case to camel case strategy see the
CamelCaseStringConverter
from Cucumber 1/2.xNote: if this feature is not introduced in a major release it must be off by default.
Context & Motivation
The infrastructure provided by #1677 makes it possible to give #1388 another shot
The text was updated successfully, but these errors were encountered: