What would be an alternate to [TearDown] and [SetU

2019-01-10 03:21发布

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?

4条回答
聊天终结者
2楼-- · 2019-01-10 03:49

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

查看更多
我命由我不由天
3楼-- · 2019-01-10 04:05

You can use [TestInitialize] for [SetUp] and [TestCleanup] for [TearDown].

查看更多
虎瘦雄心在
4楼-- · 2019-01-10 04:07

You would use [TestCleanup] and [TestInitialize] respectively.

查看更多
乱世女痞
5楼-- · 2019-01-10 04:11

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() {}
查看更多
登录 后发表回答