Russell,

Great question.  I know in the Spring-Security example, you'll find state in 
the AuthenticationSteps,
but in the OrganizationSteps and UserSteps, the state is the database - the 
steps actually create data
that the AuthenticationSteps will use.  I personally find it helpful to 
organize steps around functionality.

However, on a larger system you may need to create a model that can be gotten 
and updated from a ThreadLocal.
I've not had to do that but I've not used JBehave on a really really large 
system - or I've been able to use
the database.

Hope that helps!

Brian

----- Original message -----
From: "Russell Brown" <[email protected]>
To: "[email protected]" <[email protected]>
Date: Thu, 17 Feb 2011 14:44:58 +0000
Subject: [jbehave-user] State, context, order

Hi,
I'm trying to get my head around JBehave right now. I love using it and it is a 
great BDD project. My project is getting pretty big now and there are quite a 
lot of steps. We are striving for step reuse but I have some questions about 
the context and order of step execution.

If I use the example from your documents 
http://jbehave.org/reference/stable/developing-stories.html

In this case, if the

    When the stock is traded at 5.0

    @When("the stock is traded at $price")
    public void theStockIsTradedAt(double price) {
        stock.tradeAt(price);
    }

step  is used by a different story, one that didn't start with the


    Given a stock of symbol STK1 and a threshold of 10.0

     @Given("a stock of symbol $symbol and a threshold of $threshold")
    public void aStock(String symbol, double threshold) {
        stock = new Stock(symbol, threshold);
    }


Then you have an NPE? Is that right?

My question is really about how to manage state (or context) for a Step class. 
If your steps create/modify/read state from the enclosing class then they 
cannot really be mixed and matched, or can they?
Also, thread wise... I assume that you guarantee that only one thread runs the 
steps in sequence? And that only a single story is run at a time (IE the app is 
totally single threaded in its execution)?

In the case that a Given step from one class proceeds a When step from another 
class which proceeds a Then step from a third class, is there any shared memory 
that they call access (like a Story Context or something?)

In the case that Spring is used, all the steps will be singletons...with 
state...and resused steps may read stale state...so many questions.

Is there a simple, best practice style answer like "All Steps should be in the 
same class" or "Stories don't have state" or something like that?

Love JBehave but I really need  a steer on the above: State, Order, Threads

Many thanks

Russell

This e-mail and any attachments are confidential and intended solely for the 
addressee and may also be privileged or exempt from disclosure under applicable 
law. If you are not the addressee, or have received this e-mail in error, 
please notify the sender immediately, delete it from your system and do not 
copy, disclose or otherwise act upon any part of this e-mail or its attachments.

Internet communications are not guaranteed to be secure or virus-free. ioko365 
Limited does not accept responsibility for any loss arising from unauthorised 
access to, or interference with, any Internet communications by any third 
party, or from the transmission of any viruses.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


---
Brian Repko
LearnThinkCode, Inc.
http://www.learnthinkcode.com
email: [email protected]
phone: +1 612 229 6779


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to