Conversion from String to BigDecimal do not with Cucumber on Scala -
i'm writing tests in cucumber scala code. have following step
when added product price 10.0
and following step definition:
when( """^added product price ([\d\.]*)$""") { (price: bigdecimal) => { //something } }
i following error when run test intellij:
cucumber.runtime.cucumberexception: don't know how convert "10.0" scala.math.bigdecimal. try writing own converter: @cucumber.deps.com.thoughtworks.xstream.annotations.xstreamconverter(bigdecimalconverter.class) public class bigdecimal {} @ cucumber.runtime.parameterinfo.convert(parameterinfo.java:104) @ cucumber.runtime.stepdefinitionmatch.transformedargs(stepdefinitionmatch.java:70) @ cucumber.runtime.stepdefinitionmatch.runstep(stepdefinitionmatch.java:38) @ cucumber.runtime.runtime.runstep(runtime.java:289) @ cucumber.runtime.model.stepcontainer.runstep(stepcontainer.java:44) @ cucumber.runtime.model.stepcontainer.runsteps(stepcontainer.java:39) @ cucumber.runtime.model.cucumberscenario.run(cucumberscenario.java:40) @ cucumber.runtime.model.cucumberfeature.run(cucumberfeature.java:116) @ cucumber.runtime.runtime.run(runtime.java:120) @ cucumber.runtime.runtime.run(runtime.java:108) @ cucumber.api.cli.main.run(main.java:26) @ cucumber.api.cli.main.main(main.java:16) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ com.intellij.rt.execution.application.appmain.main(appmain.java:134)
i have tried implement own transformer can't adnotate scala.math.bigdecimal
class bigdecimalconverter extends transformer[bigdecimal] { override def transform(p1: string): bigdecimal = bigdecimal(p1) }
do have suggestion why cucumber not loading cucumber.runtime.xstream.bigdecimalconverter?
as workaround i'm passing string , create bigdecimal using it.
when( """^added product price ([\d\.]*)$""") { (price: string) => { something(bigdecimal(price)) } }
Comments
Post a Comment