Banging my head against the wall

12/01/07

Permalink 09:28:04 pm, by truewill Email , 181 words, 107 views   English (US)
Categories: Testing, IoC, Tools, SQL, Persistence

Banging my head against the wall

I’ve been trying to come up with a good way to test classes in our domain layer at work. Standard unit testing dogma is that tests should be fast and isolated. Testing against a database is not a good way to meet those criteria.

The problem is that we use persistence frameworks (O/R mappers). For Delphi we rolled our own; for .NET, we use Gentle.NET. Persisting business objects becomes very easy; however, the objects depend on the persistence layer.

So how do you mock the database? One way is to use a local or in-memory database. We’ve successfully used SQL Server Express to set up local file-based databases for testing. These can be treated as test decks, checked into source control, and restored to an initial state as needed. The main problem is that they’re a lot of work to set up, and more work to maintain as the database schema evolves.

I’m not sure what the solution is. I’m familiar with mock objects and dependency injection, but I don’t know where the interfaces belong. Suggestions are very welcome.

Comments, Pingbacks:

No Comments/Pingbacks for this post yet...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
The name truewill is composed of two other words. What is the SECOND word?

Development Central

Development Central is the blog of Bill Sorensen, a professional software developer. Much of this will relate to C#, .NET, and OOP in general.

Disclaimer
These postings are provided "AS IS" with no warranties and confer no rights.

Search

Categories

Linkblog

b2evolution

contributors

XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 3

powered by b2evolution free blog software