Understanding the MSTest TestContext

前端 未结 5 1370
一个人的身影
一个人的身影 2020-12-14 07:03

Using MSTest, I needed to obtain the name of the current test from within the [TestInitialize] method. You can get this from the TestContext.TestName

5条回答
  •  伪装坚强ぢ
    2020-12-14 07:25

    The method

    [ClassInitialize]
    public static void SetupTests(TestContext testContext) { }
    

    is called before the property set TestContext is set. So if you need the context in SetupTests then the parameter is usefull. Otherwise use the TestContext property, which is set before each

    [TestInitialize]
    public void SetupTest() { }
    

提交回复
热议问题