MbUnit has now a basic support for loading fixture and tests based on their names, such fixture are called Naked Fixtures . Although this may look like a step backward in functionality, this can be handy in particular situations. For example, if you don't want to reference any test framework, this is a good solution because it does not require any type or attribute.
Naming rules
Limitations
QuickStart
Below are two fixture. The first uses attributes and should be familiar to you. The second is it's naked equivalent:
[TestFixture] public class ClassicFixture { [TestFixtureSetUp] public void TestFixtureSetUp() { Console.WriteLine("TestFixtureSetUp"); } [SetUp] public void SetUp() { Console.WriteLine("SetUp"); } [Test] public void First() { Console.WriteLine("Test1"); } [Test] public void SecondTest() { Console.WriteLine("Test1"); } [TearDown] public void TearDown() { Console.WriteLine("TearDown"); } [TestFixtureTearDown] public void TestFixtureTearDown() { Console.WriteLine("TestFixtureTearDown"); } }
Naked version:
public class NakedFixture { public void TestFixtureSetUp() { Console.WriteLine("TestFixtureSetUp"); } public void SetUp() { Console.WriteLine("SetUp"); } public void FirstTest() { Console.WriteLine("Test1"); } public void SecondTest() { Console.WriteLine("Test1"); } public void TearDown() { Console.WriteLine("TearDown"); } public void TestFixtureTearDown() { Console.WriteLine("TestFixtureTearDown"); } }
Page rendered at Thursday, December 04, 2008 7:44:52 AM UTC
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.