Todd,

The string in the annotation is used by JBehave to create a regex
to match the line in the story.
It isn't the regex itself (although's Paul's example in etsy
might have that).
The Spring-Security example might be a good place to start if you
are looking for something
that runs like JUnit (and particularly if you are using Spring).
I need to update the PPT for it
as well but you'll find a PPT presentation that goes with that
example at

http://www.learnthinkcode.com

Brian

----- Original message -----
From: "Paul Hammant" <[email protected]>
To: [email protected]
Date: Fri, 28 Jan 2011 10:54:36 -0600
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 [1]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
<[2][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
[3]http://jbehave.org/reference/latest/developing-stories.html
says “JBehave maps textual steps to Java methods
via [4]CandidateSteps. 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 [5]http://ViewSVN

Then I can view files without logging in


And


Given I open a new web browser

When I connect to [6]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.

References

1. https://github.com/jbehave/jbehave-tutorial
2. mailto:[email protected]
3. http://jbehave.org/reference/latest/developing-stories.html
4. 
http://jbehave.org/reference/latest/javadoc/core/org/jbehave/core/steps/CandidateSteps.html
5. http://ViewSVN/
6. http://ViewCVS/
---
Brian Repko
LearnThinkCode, Inc.
http://www.learnthinkcode.com
email: [email protected]
phone: +1 612 229 6779

Reply via email to