Craig, You may find situations with transactions done that way where the software doesn't perform the same as the test.
If you're interested, the spring-security examples restore the state of the database for every story by using DbUnit, just to give you another option. Brian ----- Original message ----- From: "Craig Tataryn" <[email protected]> To: [email protected] Date: Tue, 7 Feb 2012 19:52:41 +0000 (UTC) Subject: [jbehave-user] Re: JBehave and Spring Transactions... Brian Repko <brian.repko@...> writes: > > > Craig, > > > Also when you mark the Steps class as @Transactional, Spring will create a proxy and the > @Given/@When/@Then annotated methods are not found anymore on the proxy. > A couple of folks have asked about that. It might depend on how you weave > the class (AspectJ vs Spring-AOP). Ahhhh, makes sense now. > > Also, I don't get your setup. Your Services should be @Transactional. > Your Steps classes are clients to those services. If you make the steps transactional and they rollback, > then you won't have data for your Thens. no? > And making your Stories class @Transactional makes me think that you will run the whole suite as a > transaction which could be huge transaction log at the database level and hugely slow. My services are annotated with @Transactional. You are correct though, I do want the steps to all operate within the same Transaction that my JUnit test creates. This way, I can seed data into the database before my stories run, have my services invoked by the steps munge data at will, etc... Then, when the test is over it just rolls back in the traditional SpringJUnit4ClassRunner way. Craig. > > Stories / Steps should be clients to the system under test including its transactional logic. > In my mind integration tests should restore the database (or whatever you are integrating against) into its original state after tests have run. Using a transaction does that very nicely. Thanks for the explanations, Craig. > Brian > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
