|
MbUnit : NakedFixture
This page last changed on Jul 02, 2005 by peli.
The NakedFixture is an attribute-free way of defining test fixtures in MbUnit. MbUnit has a basic support for loading fixture and tests based on their names, i.e. naked fixtures . Although this may look like a step backward in functionality, this can be handy in particular situations where you want to limit dependencies. 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
Below are two fixture. The first uses attributes and should be familiar to you. The second is it's naked equivalent: Classic TestFixture versionUnable to find source-code formatter for language: cs. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml [TestFixture] public class ClassicFixture { [TestFixtureSetUp] public void TestFixtureSetUp() { Console.WriteLine("TestFixtureSetUp"); } [SetUp] public void SetUp() { Console.WriteLine("SetUp"); } [Test] public void FirstTest() { Console.WriteLine("Test1"); } [Test] public void SecondTest() { Console.WriteLine("Test2"); } [TearDown] public void TearDown() { Console.WriteLine("TearDown"); } [TestFixtureTearDown] public void TestFixtureTearDown() { Console.WriteLine("TestFixtureTearDown"); } } NakedFixture version:Unable to find source-code formatter for language: cs. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml 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("Test2"); } public void TearDown() { Console.WriteLine("TearDown"); } public void TestFixtureTearDown() { Console.WriteLine("TestFixtureTearDown"); } } |
| Document generated by Confluence on Jun 11, 2007 11:56 |