Banging my head against the wall


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.

Your Host:
Copyright © 2000-2013 by William Sorensen. All rights reserved.