Woah, Nellie.NET!

From my simple mind to… mine…

Testing NHibernate

with one comment

I started reworking one of my projects that utilizes NHibernate. One of the challenges with using NHibernate as a data access platform is what I consider “proper” data access unit testing.

That is:

1. Database unit testing, if it is included as part of your overall unit test framework, should be relatively quick.

2. The database should be preconfigured for each and every data access unit test and left in the state it was found once the unit test completes.

3. Other parts of the system, when unit tested, should not have to touch the database for acquiring their test data. They should work through an abstraction of some sort (interface) that delivers the expected data.

So, with these objectives in mind, I started looking around the web to see what I could find.

Ayende’s blog is probably the most practical source of information for NHibernate, NHibernate tools, and best practices. His NHibernate Generics framework, Rhino mocks unit testing tool and general passion for domain driven development and unit testing are amazing. (Not to mention his prolific ability to code and post bog entries!!)

From his site, I acquired Rhino mocks, the NHibernate Generics library, ideas for a Generic Data Access interface and the NHibernate Query Generator. All awesome tools, but most importantly, his suggested practices are what I pulled from to derive my solution to help accomplish my goals.

NDbUnit seems to be useful for my objective of setting up and leaving the DB in a known state.

More to come…


Written by Nelson

December 16, 2006 at 8:47 pm

Posted in Uncategorized

One Response

Subscribe to comments with RSS.

  1. Good to know. To this point I’ve found testing around database code very difficult.


    January 5, 2007 at 4:12 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: