Now that I've installed the latest MbUnit from TestDriven.NET I can make use of the TestFixtureSetUp and TestFixtureTearDown support in MbUnit (+ Assembly Setup and TearDown).
This has greatly simplified my code. In each of my test fixtures I used to have to have a SetUp method which calls a static initializer from another class to initialize my log4net stuff:public class MyTests
Now all I need is:
{
[SetUp]
public static void SetUp()
{
StaticInitializer.Initialize()
}
[Test]
public voidSomeTest()
{
...
}
}
public static class StaticInitializer
{
private static bool s_bIsInitialized = false;
public static void Initialize()
{
if (!s_bIsInitialized)
{
log4net.Config.BasicConfigurator.Configure (...);
s_bIsInitialized = true;
}
}
}
public class MyTests
The rest is handled for me.
{
//No extra stuff at all
[Test]
public voidSomeTest()
{
...
}
}
[assembly: AssemblyCleanup (typeof (StaticInitializer))]
public static class StaticInitializer
{
[SetUp]
public static void Initialize()
{
log4net.Config.BasicConfigurator.Configure (...);
}
}
Sooo much nicer.
Saturday, October 09, 2004
Another keeper from MbUnit: AssemblySetUp/TearDown
Posted by BigEasy at 10/09/2004 01:02:00 AM
Subscribe to:
Post Comments (Atom)
1 comment:
And don't forget you can also cleanup things in the TearDown method, which is not acheivable using a static constructor approach :)
Peli.
Post a Comment