MSTest Assert Fail 消息用处不大

MSTest Assert Fail messages are less useful

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

Message: Assert.IsTrue failed. 

但是测试方法中有很多Assert.IsTrue。那么,如果我们可以添加一条将出现在上面这条消息中的自定义消息,那不是很有帮助吗?至少它失败的行的行号?这让我烦恼了很长时间。

我是否错过了 VS 或 MS 测试中的任何 hack 或有用功能来解决这个问题?

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

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