Hi, I have a test like this: Given I have book ISBN001 that sells at 20 $ Given the discount is 10 % When i shop for the book ISBN001 Then the price of the book must be 18 $
Is it a good idea to to use JPA/Hibernate to setup test data in @Given? I cant get Hibernate to work without using AbstractTransactionalJUnitSpringTest. Webapp cannot access data since Transaction in @Given are not committed to DB. It's more tempting and readable to use data setup in @Given than a dbunit file. Is there any way to get this working? Thanks, Sathish On Sun, Feb 27, 2011 at 11:05 PM, Brian Repko < [email protected]> wrote: > > Don't make the tests transactional...that is more for unit testing than > ATDD/BDD/functional testing. I'll start with a clean database (use > dbunit but only to wipe the data - or have hibernate/spring startup > do that) but then let my tests actually hit the database. > > Brian > > ----- Original message ----- > From: "Sathish Kumar" <[email protected]> > To: [email protected] > Date: Sun, 27 Feb 2011 21:24:28 +0530 > Subject: [jbehave-user] Test data setup considerations > > Hi, > Are there any good practices for Test data setup with JBehave. > I tried the following approaches: > > 1. Use DbUnit to setup data and Run scenarios (Works perfectly) > > 2. Use builder/factory and Given methods to setup data > Ex: Given the store has book titled Spring which sells at 20 $ > will internally use BookFactory to persist book and Then will check the > webapp. > > I haven't had success in the 2nd approach due to Transactions not being > committed. > > Do you have any suggestions on this? > > Thanks, > Sathish > --- > Brian Repko > LearnThinkCode, Inc. <http://www.learnthinkcode.com> > email: [email protected] > phone: +1 612 229 6779 >
