cucumber/cucumber-jvm — Issue #90: Cryptic error when an optional scalar is not present in step
Author: gisode
Created: 2011-11-14 13:46:28+00:00
State: open

Given the stepdef

@Given("^foo (?:(\\d+) )?bar$")
public void foo(Integer i) {
}

Then the step

Given foo 3 bar

works fine but

Given foo bar

throws

com.thoughtworks.xstream.converters.ConversionException: Cannot parse date null
at cucumber.runtime.converters.ConverterWithFormat.fromString(ConverterWithFormat.java:26)
at cucumber.runtime.converters.ConverterWithNumberFormat.fromString(ConverterWithNumberFormat.java:19)
at cucumber.runtime.converters.ConverterWithNumberFormat.fromString(ConverterWithNumberFormat.java:1)
at com.thoughtworks.xstream.converters.SingleValueConverterWrapper.fromString(SingleValueConverterWrapper.java:41)
at cucumber.runtime.StepDefinitionMatch.transformedArgs(StepDefinitionMatch.java:78)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:44)

when it should set the parameter `i` to `null`.

In regard to the error message, this is related to #88