be careful though with the transaction roll back approach, it can hide
some subtle bugs, which may only be found by committing to a db. I
seen a project where they had a all their repositories tested by
executing queries and then rolling back the transaction, but when they
went to production there were quite a few bugs. In the end they had to
write integration tests to flush these out.
IMO at some point you still need to test the integration/functional
parts, to ensure things are working, and there is little benefit in
testing the queries alone
On Jan 16, 8:46 am, "Troy Tuttle" <
troyltut...@gmail.com> wrote:
> I've heard others using the transaction approach as well. It would
> definitely help streamline the setup/teardown code.
>
> Thanks.
>
> On Fri, Jan 16, 2009 at 3:06 AM, Roger Kratz <
Roger.Kr...@teleopti.com>wrote:
>
> > There are many different approaches for this, I prefer (I'm using naked
> > nunit, don't know much about nDbUnit)…
>
> > * Create the db-schema (and some must-have-data in db) in setupfixture,
> > using SchemaExport
>
> > * Run every test in a tran that's rollbacked after the test
>
> > Works in 95% of the cases for me.
>
> > *From:*
nhu...@googlegroups.com [mailto:
nhu...@googlegroups.com] *On
> > Behalf Of *Troy Tuttle
> > *Sent:* den 16 januari 2009 02:32
> > *To:*
nhu...@googlegroups.com
> > *Subject:* [nhusers] Re: Testing NHibernate, Mocking ISession
>
> > Yes, by itself it is very similar. But when we get to a full suite of
> > integration tests, I have to manage cleanup so the db is in a good state
> > before the next test runs. But an in-memory collection will be cleaned up
> > for me automatically by the garbage collector (or at least I don't have to
> > worry about it).
>
> > On Thu, Jan 15, 2009 at 4:36 PM, Roger Kratz <
Roger.Kr...@teleopti.com>
> > wrote:
>
> > <<It's a lot easier to create an in-memory list of customers to query
> > against than setup records in the db.>>
>
> > Why? Maybe I'm missing something but...
> > inMemList.Add() vs repository.Add() is pretty similar?
>
> > ________________________________
> > Från:
nhu...@googlegroups.com [
nhu...@googlegroups.com] för Troy Tuttle
> > [
troyltut...@gmail.com]
> > Skickat: den 15 januari 2009 22:29
> > Till:
nhu...@googlegroups.com
> > Ämne: [nhusers] Re: Testing NHibernate, Mocking ISession
>
> > That's what we are currently doing now, but as the domain model grows, the
> > integration tests can get huge when testing queries with multiple criteria
> > (like a search screen). I'm finding most of the work is in getting the
> > database in the correct state for these kinds of respository/integration
> > testing. So, my thought is, just test the integration by using
> > PersistenceSpecification.VerifyTheMappings(), and test the queries in
> > isolation (mocked). It's a lot easier to create an in-memory list of
> > customers to query against than setup records in the db.
>
> > Thanks for the feedback though.
>
> > tt
>
> > On Thu, Jan 15, 2009 at 2:47 PM, isaiah perumalla <
> >
isaiahperuma...@googlemail.com<mailto:
isaiahperuma...@googlemail.com>>