What would be an alternate to [TearDown] and [SetUp] in MSTest?
Keep in mind that your Initialize/Cleanup methods have to use the right signature.
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.classinitializeattribute.aspx
[AssemblyInitialize()]
public static void AssemblyInit(TestContext context) {}
[ClassInitialize()]
public static void ClassInit(TestContext context) {}
[TestInitialize()]
public void Initialize() {}
[TestCleanup()]
public void Cleanup() {}
[ClassCleanup()]
public static void ClassCleanup() {}
[AssemblyCleanup()]
public static void AssemblyCleanup() {}
You can use [TestInitialize]
for [SetUp]
and [TestCleanup]
for [TearDown]
.
You would use [TestCleanup]
and [TestInitialize]
respectively.
[TestInitialize]
and [TestCleanup]
at the individual test level, [ClassInitialize]
and [ClassCleanup]
at the class level.