Skip to content
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

cucumber.runtime.CucumberException: No such field #1076

Closed
taringamberini opened this issue Oct 25, 2016 · 2 comments
Closed

cucumber.runtime.CucumberException: No such field #1076

taringamberini opened this issue Oct 25, 2016 · 2 comments
Labels
⚡ enhancement Request for new functionality

Comments

@taringamberini
Copy link

Summary

I get the exception:

cucumber.runtime.CucumberException: No such field
  mypackage.model.Person.birthPlace
    at cucumber.runtime.table.TableConverter.toListOfComplexType(TableConverter.java:106)
    at cucumber.runtime.table.TableConverter.convert(TableConverter.java:91)
    at cucumber.runtime.StepDefinitionMatch.tableArgument(StepDefinitionMatch.java:97)
    at cucumber.runtime.StepDefinitionMatch.transformedArgs(StepDefinitionMatch.java:74)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
    at cucumber.runtime.Runtime.runStep(Runtime.java:300)
    at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
    at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
    at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:102)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:95)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:38)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
    at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:38)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:532)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1179)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:1030)

with the following feature:

    Feature: Create account
        Scenario: Save person data
        Given the authenticated person fills the form with:
      | name | ... | birthPlace | ... |
      | Ann  |     | Paris      | ... |

with the following scenario:

    @Given("^the authenticated person fills the form with:$")
    public void theAuthenticatedPersonFillsTheFormWith(List<Person> personList) throws Throwable {
        ...

and with the following Person bean:

    public class Person implements Serializable {

        private String name;
        private BirthAddress birthAddress;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getBirthPlace() {
            if (birthAddress != null) {
                return birthAddress.getBirthPlace();
            } else {
                return null;
            }
        }

        public void setBirthPlace(String birthPlace) {
            birthAddress = new BirthAddress();
            birthAddress.setBirthPlace(birthPlace);
        }

    }

Expected Behavior

Cucumber should be able to convert the data table in the List<Person>.

Current Behavior

Cucumber is not able to understand the existence of the property birthPlace, even if exist getBirthPlace and setBirthPlace.

Possible Solution

1

Add private String birthPlace; to Person bean, but I don't like having to change my model to run cucumber test.

2

Leave DataTable as method parameter type:

    @Given("^the authenticated person fills the form with:$")
    public void theAuthenticatedPersonFillsTheFormWith(DataTable personList) throws Throwable {
        ...

and convert manually to List<Person>. I'll go for this boring solution.

Steps to Reproduce (for bugs)

See summary example, then run cucumber.

Context & Motivation

I'd like to use my rich data model.

Your Environment

OS: Windows 7 professional
IDE: Netbeans
JARS:

  • cucumber-core-1.2.5.jar
  • cucumber-html-0.2.3.jar
  • cucumber-java-1.2.5.jar
  • cucumber-junit-1.2.5.jar
  • cucumber-jvm-deps-1.0.5.jar
  • gherkin-2.12.2.jar
  • hamcrest-core-1.3.jar
  • junit-4.12.jar
@sebrose sebrose added Won't Fix ⚡ enhancement Request for new functionality labels Nov 17, 2016
@sebrose
Copy link
Member

sebrose commented Nov 17, 2016

Cucumber-JVM uses a 3rd party library, XStream (http://x-stream.github.io/), to do automatic conversions. It's extremely unlikely that we'll be adding this automatic conversion.

You could convert to one of the more generic List/Map formats (or use DataTable) and write a simple adaptor.

@sebrose sebrose closed this as completed Nov 17, 2016
@lock
Copy link

lock bot commented Oct 25, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⚡ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants