如何中止测试方法的继续运行

本文关键字:继续 运行 测试方法 何中止 | 更新日期: 2023-09-27 18:19:18

这是我想要的

[TestMethod]
public static void T1()
{
    if (...)
        //continue the test
    else
        //abort the test from continueing.
}

如果一个测试方法符合特定条件,我想中止它的继续。

如何中止测试方法的继续运行

不能直接用return语句

[TestMethod]
public static void T1()
{
    if (...)
    {
        //continue the test
    }
    else
    {
        return;
    }
}
 public static void T1()
    {
        if (...)
        //continue the test
        else
         {
          //abort the test from continueing.
         return; //this will do the trick
         }
    }