Carlus Henry <carlushenry@...> writes: > > > 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 <brian.repko- [email protected]> wrote: > > > > Carlus, > > Look at Spring's org.springframework.test.context.transaction.TransactionalTestExecutionListenerI 'm not sure that you need to do the <at> BeforeTransaction / <at> 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 >
I'm having a very similar problem and I just can't figure out how to get my Spring transactions working across all my steps. My situation is this: * I have a Stories class which uses a SpringJUnit4ClassRunner: https://gist.github.com/1752773 * The embedder class looks like so: https://gist.github.com/1752899 * I have a Steps class which inserts some data into a table via a JdbcTemplate and uses my Service class to read back the data using JPA: https://gist.github.com/1752795 The Stories class has been marked @Transactional(readOnly = false). The problem I'm having is, there doesn't seem to be a Transaction present when it comes time to execute my service code to retrieve player info and thus it doesn't participate in the same transaction as the JdbcTemplate INSERTS. I can even put a call to my retrieval service right below JdbcTemplate INSERT statements and still it can't find the records inserted into the database. Has anyone else run into a similar situation and if so, how did you fix it? Thanks, any help/guidance would be greatly appreciated. Craig. P.S. On a strange note: if I annotate my Steps class with @Transactional, all my steps get reported as "PENDING", essentially in the eyes of jBehave they disappear... --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
