views:

39

answers:

2

I have a rather large set of integration tests developed in C#/NUnit. Currently it is one test fixture, one class. In [TestFixtureSetUp] I create a database from a script and populate it with test data, also from a script. My tests do not modify data, so they can run in any order or in parallel.

My problem is that I have too many tests and the file is growing too big, so it looks ugly, and my ReSharper is getting sluggish. I want to split the file, but I really want to create my test database only once. As a temporary measure, I am moving the code which does actual testing into static methods in other classes, and invoke them from a single TextFixture class, as follows:

[Test]
public void YetAnotherIntegrationTest()
{
    IntegrationTestsPart5.YetAnotherIntegrationTest(connection);
}

Yet it still looks ugly and I think there should be a better way.

I am using VS 2008, upgrading to 2010 right now, and SQL Server 2005.

+2  A: 

You could split your test class into several partial classes across mutliple files. This way you can keep one [TestFixtureSetup] and split the file up for cleanliness.

pattertj
Worked for me, thanks!
AlexKuznetsov
+1  A: 

You could consider wrapping your database connection in a sigleton class, which would initialize the database while creating the singleton instance. Then you can have as many test classes as you like, just grab the db connection from the singleton.

Grzenio
+1 It worked, thanks!
AlexKuznetsov