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

Reply via email to