Brian....

Thanks once again.  I will look into the TransactionalTestExecutionListener.
 You also make valid points about using a fresh database and examining the
resource strategy as well.

Thanks again...

On Mon, Jan 3, 2011 at 3:30 PM, Brian Repko
<[email protected]>wrote:

>
> Carlus,
>
> Look at Spring's*
> org.springframework.test.context.transaction.TransactionalTestExecutionListener
> *
>
> I'm not sure that you need to do the @BeforeTransaction / @AfterTransaction 
> logic - perhaps
> you would - but that code should be the basis of your code - the 
> beforeTestMethod and
> afterTestMethod should be like BeforeScenario and AfterScenario.
>
> I'm assuming that you'll always rollback.
>
> In terms of the resource setup strategy - I get that that might be a 
> limitation - but you
> shouldn't be running tests against real data - how can you guarentee your 
> regression testing
> isn't failing based on bad data?  The use of another database - setup from 
> scratch however
> you do that - is highly recommended for acceptance testing.  That's why DbFIT 
> is so popular
> for FIT testing.
>
> B
>
> ----- Original message -----
>
>   From: "Carlus Henry" <[email protected]>
> To: [email protected]
> Date: Mon, 3 Jan 2011 14:32:05 -0500
> Subject: Re: [jbehave-user] JBehave and Spring Transactions...
>
> Thank you Brian and Mauro,
>
> With your suggestions, I think that I am closer than I was before.  I now
> have my story running within a single Spring Test that automatically roll
> backs the transaction after the story has completed.  However, as Brian
> alluded to, I would like for the transaction to rollback after every
> scenario, so that the changes to my persistent store do not impact other
> scenarios in the same story.  Any specifics that you would provide regarding
> how to control the transaction rollback in the Before and AfterScenario's
> would be greatly appreciated
>
> Brian, I would love it if I could adjust my resource setup strategy, but
> unfortunately I don't think that is going to be an option at the company I
> am working at.
>
> Thanks again for all of your help thus far...
>
> On Mon, Jan 3, 2011 at 7:44 AM, Brian Repko <
> [email protected]> wrote:
>
>
> Carlus,
>
> You may also want to look at the Spring Security example.
>
> If you are calling into your services during your steps, then you need to
> create a Spring
> Transaction in a BeforeScenario and then rollback in the AfterScenario.
> And your services
> cannot use REQUIRES_NEW.  This can be quite tricky to do for
> integration/acceptance
> tests as you are really mimicing a client of the software - be it at the
> service level or at the
> UI level (Selenium for web apps).  The acceptance test covers multiple
> "transactions" and
> if that was all one transaction you might find problems with timeouts as
> well.
>
> Rather than using a transactional rollback strategy, you might look at a
> resource setup
> strategy. In the Spring Security example, you'll see that the database
> (hsqldb) is created
> with the the construction of the application context.  You'll also see the
> use of dbunit in
> a Before and AfterScenario to wipe out all the data.
>
> Brian
>
>
>  ----- Original message -----
> From: "Carlus Henry" <[email protected]>
> To: [email protected]
> Date: Sun, 2 Jan 2011 15:59:11 -0500
> Subject: [jbehave-user] JBehave and Spring Transactions...
>
> Good afternoon,
>
> I am in the process of evaluating JBehave as our BDD testing framework.  I
> am really enjoying the features and functionality that it provides, however,
> I am a little puzzled about something and I am hoping that you would be able
> to help.
>
> Currently, most of our tests are using JUnit 3 and extends Spring's
> AbstractJpaTests, which rolls back transactions auto-"magically".  What I
> would like to do is create integration tests using JBehave and have anything
> that I do to the database rollback, after each scenario.  I had a discussion
> with some folks at work and we were coming up with all kinds of different
> ways of potentially making this work.  (Including using JUnit 4, and a
> combination of the following annotations @Transactional, @BeforeScenario,
> @AfterScenario).  I did try it, but it didn't quite work out.
>
> After scouring your mailing list and looking online, I did not find
> anything that was extremely helpful with this predicament.  This is a batch
> application and not a web application.  Any advice you can offer would be
> great.
>
> Thanks
> Carlus
>    ---
> Brian Repko
>  LearnThinkCode, Inc. <http://www.learnthinkcode.com>
> email: [email protected]
> phone: +1 612 229 6779
>
>
>
>
> --
> Carlus Henry
> SageTech L.L.C.
> 616.558.4536 cell
> www.sagetech-llc.com | http://jdcarlflip.blogspot.com/
>  ---
> Brian Repko
> LearnThinkCode, Inc. <http://www.learnthinkcode.com>
> email: [email protected]
> phone: +1 612 229 6779
>



-- 
Carlus Henry
SageTech L.L.C.
616.558.4536 cell
www.sagetech-llc.com | http://jdcarlflip.blogspot.com/

Reply via email to