This page last changed on Jul 02, 2005 by peli.

All fixture in MbUnit generally support a setup method tagged with SetUpAttribute, which is called once before each test, and teardown method
tagged with TearDownAttribute, which is called once after each test.

Unable to find source-code formatter for language: cs. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
[TestFixture]
public class SampleFixture
{
   private Foo foo;
   [SetUp]
   public void MySetUp()
   {
       foo = new Foo(); 
   }    
    ...

   [TearDown]
   public void MyTearDown()
   {
       if (foo!=null)
       {
          foo.Dispose();
          foo=null;
       }
   }
}

Rationale

  • zero or one setup method per class,
  • zero or one teardown method per class,
  • if setup fails, the test is not executed and set to failed,
  • if teardown fails, the test is set to failed,
  • teardown is always executed even if setup fails
Document generated by Confluence on Jun 11, 2007 11:56