Coder Perfect

In MSTest, what would be an alternative to [TearDown] and [SetUp]?


MSTest Framework does not recognize [TearDown] and [SetUp] when I use MSTest Framework and copy the code that Selenium IDE provided for me. What other options do you have?

Asked by Maya

Solution #1

You’d use [TestCleanup] and [TestInitialize] to clean up and initialize your tests, respectively.

Answered by Tejs

Solution #2

Remember to utilize the correct signature in your Initialize/Cleanup procedures.

    public static void AssemblyInit(TestContext context) {}

    public static void ClassInit(TestContext context) {}

    public void Initialize() {}

    public void Cleanup() {}

    public static void ClassCleanup() {}

    public static void AssemblyCleanup() {}

Answered by Dunken

Solution #3

At the individual test level, [TestInitialize] and [TestCleanup], and at the class level, [ClassInitialize] and [ClassCleanup].

Answered by John Gardner

Solution #4

For [SetUp] and [TearDown], you can use [TestInitialize] and [TestCleanup].

Answered by Mohsin Awan

Post is based on