Cannot find Assert.Fail and Assert.Pass or equivalent

后端 未结 4 987
太阳男子
太阳男子 2021-02-04 23:05

I used to use these in NUnit and they are really useful. Any idea how to do something like that?

EDIT, CODE SAMPLE:

        bool condition = false;//woul         


        
4条回答
  •  一整个雨季
    2021-02-04 23:54

    Another way to get Pass assert is to create new assert.

    public static class ExtraAssert
    {
        public static void Pass(this Microsoft.VisualStudio.TestTools.UnitTesting.Assert assert)
        {
            return;
        }
     }
    

    There is a catch however, because you could only access that method using 'That' keyword.

    Assert.That.Pass();
    

    ref: https://www.meziantou.net/mstest-v2-create-new-asserts.htm

提交回复
热议问题