Using MSTest how can I verify the exact error message coming from a test method? I know [ExpectedException(typeof(ApplicationException), error msg)]
doesn\'t co
In MSTest there's no built-in way of doing it. This is about as 'elegant' as it gets:
[TestMethod]
public void Test8()
{
var t = new Thrower();
try
{
t.DoStuffThatThrows();
Assert.Fail("Exception expected.");
}
catch (InvalidOperationException e)
{
Assert.AreEqual("Boo hiss!", e.Message);
}
}
However, you could consider porting xUnit.NET's Assert.Throws API to a custom library - that's what we did.
You could also go to Microsoft Connect an vote on this suggestion.