Created
April 23, 2012 12:12
-
-
Save tknerr/2470556 to your computer and use it in GitHub Desktop.
cucumber-jvm: @XStreamConverter not registered for normal step parameters, only works within data tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Foo Feature | |
Scenario: do some foo | |
Given I have some foo named "MyFoo" | |
Scenario: do some foo with data table first | |
Given I have some foo's in a data table: | |
| foo | | |
| MyFooToo | | |
Given I have some foo named "MyFoo" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package features.foo; | |
import org.junit.runner.RunWith; | |
import cucumber.junit.Cucumber; | |
@RunWith(Cucumber.class) | |
@Cucumber.Options( | |
format = {}, monochrome = true, | |
features = { "features/foo.feature" }) | |
public class foo_Test { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package features.foo; | |
import java.util.List; | |
import junit.framework.Assert; | |
import cucumber.annotation.en.Given; | |
import cucumber.runtime.xstream.annotations.XStreamConverter; | |
import cucumber.runtime.xstream.converters.basic.AbstractSingleValueConverter; | |
public class FooStepDefs { | |
@Given("^I have some foo named \"([^\"]*)\"$") | |
public void I_have_some_foo_named(Foo foo) { | |
Assert.assertNotNull(foo.getName()); | |
} | |
@Given("^I have some foo's in a data table:$") | |
public void I_have_some_foo_s_in_a_data_table(List<FooInTable> foosInTable) { | |
for (FooInTable fooInTable : foosInTable) { | |
Assert.assertNotNull(fooInTable.foo.getName()); | |
} | |
} | |
public static class FooInTable { | |
public Foo foo; | |
} | |
public static class FooConverter extends AbstractSingleValueConverter { | |
@Override | |
public boolean canConvert(Class type) { | |
return type.equals(Foo.class); | |
} | |
@Override | |
public Object fromString(String name) { | |
return FooFactory.createFoo(name); | |
} | |
} | |
@XStreamConverter(FooConverter.class) | |
public static final class Foo { | |
private String name; | |
Foo(String name) { | |
this.name = name; | |
} | |
public String getName() { | |
return name; | |
} | |
} | |
public static class FooFactory { | |
public static Foo createFoo(String name) { | |
return new Foo(name); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.ClassCastException: cucumber.runtime.xstream.converters.reflection.ReflectionConverter cannot be cast to cucumber.runtime.xstream.converters.SingleValueConverter | |
at cucumber.runtime.StepDefinitionMatch.transformedArgs(StepDefinitionMatch.java:92) | |
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:43) | |
at cucumber.runtime.Runtime.runStep(Runtime.java:255) | |
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:36) | |
at cucumber.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:76) | |
at cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:65) | |
at cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:20) | |
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) | |
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) | |
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) | |
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) | |
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) | |
at org.junit.runners.ParentRunner.run(ParentRunner.java:236) | |
at cucumber.junit.FeatureRunner.run(FeatureRunner.java:72) | |
at cucumber.junit.Cucumber.runChild(Cucumber.java:76) | |
at cucumber.junit.Cucumber.runChild(Cucumber.java:36) | |
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) | |
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) | |
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) | |
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) | |
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) | |
at org.junit.runners.ParentRunner.run(ParentRunner.java:236) | |
at cucumber.junit.Cucumber.run(Cucumber.java:81) | |
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) | |
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) | |
at ✽.Given I have some foo named "MyFoo"(features\foo.feature:4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment