Chris / Christiano,

Yes - this feels like doing TDD/unit testing via Given/When/Then
and that might not be the most appropriate use of BDD.

You could do the expects as additional @Givens

@Given a service object and DAO object
@Given the DAO object expects methodX and returns Y
@When the service method is called

The @When could do all the replays and then invoke the method.

Brian

----- Original message -----
From: [email protected]
To: [email protected]
Date: Fri, 27 Aug 2010 15:04:38 -0000 (UTC)
Subject: Re: [jbehave-user] JBehave & JMock

Brian,

Thanks but that will remove the ability to reuse the @Given method. I
would expect to have a set of Objects given many times but working on
different operations. By setting mock expectations in a Given then they
will be expected to be called every time.

I would need to say something like

Given a service object and a DAO object
Then expect the DAO methodA to be invoked by service
When the service object is invoked

Without having tried can you even swap about the logic like that?
Lexically it says the same to me?

Chris

>
> Chris,
>
> I would suggest doing the following:
>
> In the @Given method, create the service, DAO, injection, expects and
> replay
> In the @Then method, call the method
> In the @When method, verify
>
> You could then have a @AfterScenario that resets the mocks
>
> Let me know if that doesn't make sense - or I may have EasyMock and JMock
> confused.
>

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

    http://xircles.codehaus.org/manage_email



---
Brian Repko
LearnThinkCode, Inc.
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