Team Test Attributes

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


All Team Test attributes are found in the following namespace:
Microsoft.VisualStudio.QualityTools.UnitTesting.Framework


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.


[ TestInitialize ]
public void TestInitalize()
{ }


[ TestCleanup ]
public void TestCleanup()
{ }



 

This entry was posted in Uncategorized and tagged . Bookmark the permalink.