Thanks, Paul. That looks very helpful. But the answer to my question isn't quite clear to me, so let me rephrase it.
I imagine that as I have more than one QA tester writing stories, their syntax may not always be the same even when they're doing the same thing. In my example below, one guy's natural way of stating the "Then" is to say "Then I can view files without logging in" but another guy's way is "Then I can view files in my browser." As the guy implementing the steps in Java, I see both buys meant the same thing, and I really only need one Java method to do both of them. So I could: a) Tell the second guy, "Hey, could you rephrase that like your coworker did?" or b) Use an @Alias to say those two complete When clauses are equivalent or c) Write a regular expression that matches both When clauses Approaches (a) and (b) are obvious, but I was trying to figure out how to do (c). Is it possible? Or do people who use this ever do (c)? Thanks, Todd. From: Paul Hammant [mailto:[email protected]] Sent: Friday, January 28, 2011 9:55 AM To: [email protected] Subject: Re: [jbehave-user] regex examples, please Yup. JBehave is more "in the box" as its easy to sell as a Junit plugin. Take a look at https://github.com/jbehave/jbehave-tutorial particularly a dir called etsy-stories/ and the Groovy classes within. You'll note that the steps class has a few examples. The regex is simpler in JBehave too. Just use replacement var names (and JBehave itself makes the actual regex). You might like to fork that project as a starting point :) - Paul On Fri, Jan 28, 2011 at 10:37 AM, Bradley, Todd <[email protected]<mailto:[email protected]>> wrote: Hi, I'm a new user of JBehave. I'm exploring it as a simpler alternative to Cuke4Duke (and its required technology stack) since our development environments are almost pure Java. I'm doing a proof-of-concept using JBehave to test the product I develop, and am writing various story scenarios. I'm so much happier with the "new user" type examples and documentation for JBehave than for Cucumber/Cuke4Duke. But I can't find an example of using a regular expression to map a string in a When clause to a Java method. The page http://jbehave.org/reference/latest/developing-stories.html says "JBehave maps textual steps to Java methods via CandidateSteps<http://jbehave.org/reference/latest/javadoc/core/org/jbehave/core/steps/CandidateSteps.html>. The scenario writer need only provide annotated methods that match, by regex patterns, the textual steps." I took that to mean I could do something like this in my Java steps file: @Then("I can view files.*") public void canViewFiles() { // blah blah blah } So that this code would match both Given I open a new web browser When I connect to http://ViewSVN Then I can view files without logging in And Given I open a new web browser When I connect to http://ViewCVS Then I can view files on my screen But the @Then("I can view files.*") doesn't match either of those. Neither does "I can view files(.*)" So what kind of "regex patterns" is the JBehave web page talking about? Or am I missing the real meaning of "The scenario writer need only provide annotated methods that match, by regex patterns, the textual steps"? Thanks, Todd.
