Tue Jul 05 2005

A quick breakdown of the Team Test.aspx) attributes compared to NUnit attributes with a few examples.

All Team Test.aspx) attributes are found in the following namespace:


Attribute Quick List

Team Test NUnit
TestClass TestFixture
AssemblyInitialize N/A
AssemblyCleanup N/A
ClassInitialize TestFixtureSetUp
ClassCleanup TestFixtureTearDown
TestInitialize SetUp
TestCleanup TearDown
TestMethod Test

AssemblyInitalize and AssemblyCleanup are new. There are no equivalent attributes in NUnit. These attributes run at AppDomain load and dispose. ` ``

[ AssemblyInitialize ]

public static void AssemblyInitialize() { }

[ AssemblyCleanup ]

public static void AssemblyCleanup() { } `

Acting just like the NUnit TestFixtureSetUp and TestFixtureTearDown with the only one minor difference. Both methods have to be static and the ClassInitialize takes in one parameter. ClassInitialize will execute before any TestInitialize and TestMethod after the AssemblyInitialize while ClassCleanup executes after the TestMethod and TestCleanup but before the AssemblyCleanup. ` ``

[ ClassInitialize ]

public static void ClassInitialize(TestContext t) { }

[ ClassCleanup ]

public static void ClassCleanup() { } `

TestInitialize executes before each test and TestCleanup executes after each test for every TestMethod. <SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"></SPAN>

`[ TestInitialize ]

public void TestInitalize() { }

[ TestCleanup ]

public void TestCleanup() { } `