On 19 Sep 2012, at 17:26, Rob McDiarmid wrote:
Hi,
I'm trying to use a step definition like this:
@Then("^I should( not)? see the error message \"([^\"]*)\"$")
public void I_should_see_the_error_message(boolean errorMessageShouldNotExist, String errorMessage) { ... }
If I have a cucumber step like - Then I should see the error message "Some error Message"
Then errorMessageShouldNotExist is false as I would expect but the console only outputs "Then" instead of the whole cucumber step.
I don't know much about how Cucumber-JVM matches steps, but it looks like your regular expression is wrong. You are capturing the pattern ( not) optionally, and I'd be surprised if Cucumber-JVM were clever enough to turn that into a boolean. My guess is that you've confused it.
I would suggest doing something more like this:
@Then("^I (should|should not) see the error message \"([^\"]*)\"$")
public void I_should_see_the_error_message(String maybe, String errorMessage) { ... }
Then check the value of the maybe string to see whether it contains 'should' or 'should not'.
If I have a cucumber step like - Then I should not see the error message "Some error Message"
Then errorMessageShouldNotExist is still false which I would not expect and the console outputs the expected step.
Anyone know how to accomplish this sort of functionality in cucumber JVM?
Thanks!
--
-- Rules --
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en