Core: TableConverter extracts child object values but not headers
See original GitHub issueHi! I’d like to report a bug I encountered while trying out Cucumber on my freshly-converted Kotlin Android application. I’m not entirely sure if this is a bug with Cucumber or Kotlin, so I’ll let you judge.
Steps to reproduce
- Given TimeoLine.kt
data class TimeoLine (val id: String, val name: String, val direction: TimeoDirection, val networkCode: Int = 147, val color: String = "#34495E") {
override fun toString(): String = name
}
- Given TimeoDirection.kt
data class TimeoDirection (var id: String, var name: String) {
override fun toString(): String = "$id - $name"
}
nb: As you can see, TimeoLine
contains a TimeoDirection
as a property named direction
- Call
DataTable.create()
on aList<TimeoLine>
Expected behavior
The function returns a table that looks like this:
id | name | direction | networkCode | color |
---|---|---|---|---|
TRAM | Tram | A - Ifs Grace de Dieu | 147 | #ff3300 |
… | … | … | … | … |
Observed behavior
cucumber.runtime.CucumberException: Table is unbalanced: expected 5 column(s) but found 6.
at cucumber.api.DataTable.<init>(DataTable.java:63)
at cucumber.runtime.table.TableConverter.createDataTable(TableConverter.java:272)
at cucumber.runtime.table.TableConverter.toTable(TableConverter.java:258)
at cucumber.api.DataTable.create(DataTable.java:45)
at cucumber.api.DataTable.create(DataTable.java:31)
at fr.outadev.android.transport.timeo.ParseStepDefinitions.iGetTheFollowingLines(ParseStepDefinitions.kt:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at cucumber.runtime.Utils$1.call(Utils.java:37)
at cucumber.runtime.Timeout.timeout(Timeout.java:13)
at cucumber.runtime.Utils.invoke(Utils.java:31)
at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:38)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:299)
[...]
By playing a bit with the DataTable
conversion, you’ll see ComplexTypeWriter
extracts all the values in the object, including the members of TimeoDirection
; but it only extracts the headers for the properties of the parent object (TimeoLine
). It also causes some not-failing-but-extremely-confusing-behavior in diffs.
- Runtime: java-8-openjdk
- Lib version: info.cukes:cucumber-java:1.2.4
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to show values from children object when GET an API ...
I'm using the code bellow and the response has a child object, i´d like to use those childs values on my zap but...
Read more >Extracting just JSON data, not the headers, to a string array ...
The reason that I just want the data and not the headers is that the data could by dynamic. In one call the...
Read more >JavaScript object model | Apigee X | Google Cloud
This table briefly describes the context object and its children, and lists the properties that are bound to each. Name, Description, Properties. context,...
Read more >[Solved]-Entity Framework lazy loading incorrect entity-C#
When you went to reference it from another element/object, it would be silly for it to go and load it again when it...
Read more >Object.getOwnPropertyNames() - JavaScript - MDN Web Docs
The object whose enumerable and non-enumerable properties are to be returned. Return value. An array of strings that corresponds to the properties found ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As it turns out I was mistaken. To achieve the desired result you have to add a converter that tells Cucumber how to present your object in a table. This should also prevent any table imbalances.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.