When I use MSTest Framew开发者_如何学JAVAork, and copy the code that Selenium IDE generated for me, MSTest doesn't recognize [TearDown]
and [SetUp]
. What is the alternative to this?
You would use [TestCleanup]
and [TestInitialize]
respectively.
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() {}
[TestInitialize]
and [TestCleanup]
at the individual test level, [ClassInitialize]
and [ClassCleanup]
at the class level.
You can use [TestInitialize]
for [SetUp]
and [TestCleanup]
for [TearDown]
.
精彩评论