cucumber-attic / cuke4duke

Cucumber support for the JVM: Java, Scala, Groovy, Clojure, Ioke, Javascript, Spring, Guice, PicoContainer, WebDriver, Ant and Maven
http://wiki.github.com/aslakhellesoy/cuke4duke
MIT License
256 stars 72 forks source link

Step definitions with optional regex matching groups doesn't work. #103

Open borisbrodski opened 13 years ago

borisbrodski commented 13 years ago

Consider following step definition: @Then("^I( don't)? see the Text \"([^"]*)\"$") public void seeOrDoesntSeeText(String dont, String text) { if (dont != null) { assertFalse(seeText(text)); } else { assertTrue(seeText(text)); } }

This step definition should work with both

In Cuke4duke this produces IndexOutOfBounds exception in StepArgument class. The problem is, that the matcher.start(1) returns -1, if "don't" not there. This causes wrong call to the StepArgument-constructor in the line

JanAhrens commented 13 years ago

Maybe it's just a typo, but in your example, you write "doesn't" and your regex contains "don't" ...

borisbrodski commented 13 years ago

Yes, it's a type. Sorry for that.

borisbrodski commented 13 years ago

I would like to point out, that the problem still exists. The typo is only in the posted example.

bcluca commented 13 years ago

Hi, I see you have the same issue here.

Have a look at https://github.com/cucumber/cuke4duke/pull/124 and the corresponding commit for a quick patch. You can either check it out and build from source or wait for the pull request to be accepted.

Hope it helps.

borisbrodski commented 13 years ago

Cool! Thank you very much.