Please take a look at the way we test mapper: http://github.com/dpp/liftweb/blob/master/framework/lift-persistence/lift-mapper/src/test/scala/net/liftweb/mapper/MapperSpecs.scala
On Thu, Jan 14, 2010 at 3:17 PM, Ferdinand Chan <[email protected]> wrote: > One follow up question about using H2 for testing. > > Assuming I've created a DB in H2 for testing purpose. What I need to > do in the beforeAll and afterAll method? > > My initial thinking is that I need to define the connection manager > and schemify all Model in the beforeAll method, like.. > > override def beforeAll(){ > DB.defineConnectionManager(DefaultConnectionIdentifier, > H2InMemoryDBVendor) > Schemifier.schemify(true, Log.infoF _, Category) > } > > For afterAll, I think what need to be done is clean up all the data. > Do I need to do any DB connection clean up ??? > > > Or its better to create new DB on the fly and schemifier all Model > during the beforeAll and afterAll of each test suite? So that I don't > need to make sure the testing data is not polluted by other tests??? > But not sure how to create a new database in H2 on the fly, > > Would appreciate if someone can give advice on this. > > Thanks > > Ferd > > > On Jan 15, 6:04 am, Ferdinand Chan <[email protected]> wrote: > > Thanks all for quick response. > > > > Its working now... > > > > Thanks > > > > Ferd > > > > On Jan 15, 4:29 am, Jeppe Nejsum Madsen <[email protected]> wrote: > > > > > > > > > Ferdinand Chan <[email protected]> writes: > > > > Hi, > > > > > > I'm writing a unit test for a utility class that will make use of > > > > information of a Model class. Here is the sample code for the model > > > > class > > > > > > class Category extends LongKeyedMapper[Category] with IdPK{ > > > > > > def getSingleton = Category > > > > > > object parentCategoryId extends MappedLong(this) > > > > > > object name extends MappedPoliteString(this,255) { > > > > override def validations = valMinLen(1, "Category cannot be > > > > empty") _ :: super.validations > > > > } > > > > } > > > > > > In my scala test, I need to create a Category and then pass it to the > > > > utility class. Then make sure the utility class is producing result > as > > > > expected. > > > > > > But the problem is that I can't set the ID of the Category , here is > > > > my test code > > > > > val category = Category.create > > > category.runSafe { > > > category.id(1) > > > } > > > > > /Jeppe > > -- > You received this message because you are subscribed to the Google Groups > "Lift" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<liftweb%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=en. > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
