-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
One-dimensional datatable transformer behavior in Cucumber 5 does not match Cucumber 4 behavior #1928
Comments
Thanks for the massive write up!
As part of cucumber/common#540 this should have thrown an exception but but it looks like this case slipped through the cracks. An example of the exception would be:
The way to handle your current situation would be to transpose the table before transformation. You can do this using the
|
As reported in cucumber/cucumber-jvm#1928: ``` Given table1 | aaa | bbb | ccc | List<String> result1 = table1.asList(String.class); ``` As part of #540 this should have thrown an exception but no exception was thrown. After fixing this, reviewing the exceptions revealed that they were rather lacking in clarify. By including all potential causes rather then a best guess we'll ensure that all possible fixes have been suggested.
As reported in cucumber/cucumber-jvm#1928: ``` Given table1 | aaa | bbb | ccc | List<String> result1 = table1.asList(String.class); ``` As part of #540 this should have thrown an exception but no exception was thrown. After fixing this, reviewing the exceptions revealed that they were rather lacking in clarify. By including all potential causes rather then a best guess we'll ensure that all possible fixes have been suggested.
As reported in cucumber/cucumber-jvm#1928: ``` Given table1 | aaa | bbb | ccc | List<String> result1 = table1.asList(String.class); ``` As part of cucumber/common#540 this should have thrown an exception but no exception was thrown. After fixing this, reviewing the exceptions revealed that they were rather lacking in clarify. By including all potential causes rather then a best guess we'll ensure that all possible fixes have been suggested.
Nice... that suggestion along with the datatable update to 3.3.1 should solve my problem, thanks! |
As reported in #1928: ``` Given table1 | aaa | bbb | ccc | List<String> result1 = table1.asList(String.class); ``` As part of cucumber/common#540 this should have thrown an exception but no exception was thrown. After fixing this, reviewing the exceptions revealed that they were rather lacking in clarify. By including all potential causes rather then a best guess we'll ensure that all possible fixes have been suggested.
Describe the bug
When trying to transform a one-dimensional DataTable (i.e. DataTable has only one row and many columns, or only one column and many rows) into a List, the resulting output differs from Cucumber 4 behavior.
Given two DataTables as follows:
Running the following code for both versions (4.4.0 or 5.5.0)
Using Cucumber 4 (version 4.4.0) has these results:
Using Cucumber 5 (version 5.5.0) has these results:
Additionally, when using a multi-dimensional table, asList(Type) yields a
CucumberDataTableException
To Reproduce
Feature file used:
Runner class DataTableTransform_Runner.class (comment or uncomment imports depending on version):
Step definition class DataTableTestSteps.class (comment or uncomment imports depending on version):
TypeRegistration info... TypeRegistryConfiguration.class (only for version 4.4.0):
TypeRegistration info... NewTypeRegistryConfiguration.class (only for version 5.5.0):
When running the above with version 4.4.0, relevant output generated:
When running with version 5.5.0, the relevant output is:
Expected behavior
The expectation is that a one-dimensional table with only one row and many columns transforms into a List of objects, and not into an empty List.
Additionally, the expectation is that
asList()
andasList(String.class)
both produce the same output layout.Context & Motivation
We have many step definitions defined which when simplified look like this:
When attempting to update the project to version 5.5.0, with only the simple NewTypeRegistryConfiguration class shown further above, all of these steps started encountering
java.lang.IllegalArgumentException: Cannot deserialize instance of `java.lang.String` out of START_OBJECT token
(and this is was a bit of a red herring).Changing the step definitions to use a DataTable for the input parameter instead, and then transforming that table into our List showed where the actual difference was... namely the differing behavior of
asList(Type itemType)
between versions 4.4.0 and 5.5.0.Since the output of
asList()
appeared to still behave as before, we attempted to transform the table into our List with the zero-parameter call, however quickly noticed that using a replaced String transformer did not have the desired result. Using the exact same steps as shown above, but adding this method to the step definition class:Running the following scenario:
yielded this output... clearly showing that
asList()
does not use the transformer, whereasasList(String.class)
does.Your Environment
The text was updated successfully, but these errors were encountered: