When I use MSTest Framework, and copy the code that Selenium IDE generated for me, MSTest doesn't recognize [TearDown] and [SetUp]. What is the alternative to this?
Asked
Active
Viewed 9.7k times
264
Marcos Dimitrio
- 6,651
- 5
- 38
- 62
Maya
- 7,053
- 11
- 42
- 53
-
1Why do we have to always invent some new naming for the same old stuff? – safkan May 01 '21 at 16:04
4 Answers
294
Keep in mind that your Initialize/Cleanup methods have to use the right signature.
[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() {}
Dunken
- 8,481
- 7
- 54
- 87
-
10+1 for AssemblyInitialize and AssemblyCleanup not mentioned here http://stackoverflow.com/a/1873572/864201 – Rodolpho Brock Jun 23 '15 at 23:07
108
[TestInitialize] and [TestCleanup] at the individual test level, [ClassInitialize] and [ClassCleanup] at the class level.
John Gardner
- 24,225
- 5
- 58
- 76
10
You can use [TestInitialize] for [SetUp] and [TestCleanup] for [TearDown].
Rick the Scapegoat
- 1,056
- 9
- 19
Mohsin Awan
- 1,176
- 2
- 12
- 29