Search code examples
visual-studiomstest

MSTest Assert Fail messages are less useful


When running MS Test, all we get is a

Message: Assert.IsTrue failed. 

But there are many Assert.IsTrue in the test method. So wouldn't it be helpful if we could add a custom message which will appear along this message above? At least the line number of the line it failed? This has been annoying me for a long time.

Have I missed out on any hack or useful feature from VS or MS test to tackle this?


Solution

  • The method supports giving a message. If you do that, you will see a custom message:

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