dbones notes
its a geek thing

Struture of a Unit Test

April 14, 2009 22:43 by Dave

A Test fixture can be made of the following

Fixture (the following are optional)

  • FixtureSetUp - this is ran once before all the tests (set up the fixture)
  • FixtureTearDown - run after all the tests have completed (this can be used to clean up after all the tests)
  • SetUp - run before each test (set the test data to its default settings before each test)
  • TearDown - run after each test (clean up after each test)

the rest of the fixture is made up of Tests

here is a bear bone text fixture, using MbUnit 3.x

[TestFixture]
public class TestCodeFromAssembly
{
    [FixtureSetUp]
    public void FixtureSetUp()
    {
        //add code to set up the global test fixture
    }

    [FixtureTearDown]
    public void FixtureTearDown()
    {
        //Clean up the text fixure
    }

    [SetUp]
    public void TestSetup()
    {
        //run before every test
    }

    [Test]
    public void Test()
    {
        //
        // TODO: Add test logic here
        //
    }

    [TearDown]
    public void TestTearDown()
    {
        //cleans up after every test
    }
}


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Test
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts