代码之家  ›  专栏  ›  技术社区  ›  Blue Clouds

MSTest Assert Fail消息没有那么有用

  •  0
  • Blue Clouds  · 技术社区  · 6 年前

    当运行MS测试时,我们得到的只是

    Message: Assert.IsTrue failed. 
    

    但是在测试方法中有很多Assert.IsTrue。所以,如果我们可以添加一个自定义消息,它将出现在上面的消息有帮助吗?至少它失败的行的行号?这件事烦了我很久了。

    为了解决这个问题,我错过了VS或MS测试中的任何黑客或有用功能吗?

    1 回复  |  直到 6 年前
        1
  •  1
  •   nvoigt    6 年前

    该方法支持提供消息。如果这样做,您将看到一条自定义消息:

    Assert.IsTrue(yourBooleanVariable, "yourBooleanVariable was not true!")