3

我有以下试用代码:

[TestMethod]
public void VisibilitySucces()
{
    testPage.HideParagraph();
    testPage.ShowParagraph();
}

[TestMethod, ExpectedException(typeof(WebDriverTimeoutException))]
public void ShouldBeVisibleException()
{
    testPage.ShouldBeVisibleException();
}

[TestCleanup]
public void TestCleanup()
{
     switch (TestContext.CurrentTestOutcome)
     {
         case UnitTestOutcome.Passed:
               Console.WriteLine("Passed!");
               break;
         default:
               Console.WriteLine("The test outcome is " + TestContext.CurrentTestOutcome.ToString());
               break;
     }
     Browser.Quit();
}

现在,第一个测试的结果Passed符合预期。第二个测试确实引发了异常(我已经在没有ExpectedException属性的情况下对其进行了测试)。它在视觉上被标记为通过,但控制台中的结果显示InProgress

当在 中查询此状态时,怎么会这样TestCleanup

4

0 回答 0