testfx
testfx copied to clipboard
asserting Assert.ThrowsException and failing creates an exception where the message include the message and stacktrace in it
Describe the bug
In the following method the exception fails and throws AssertFailedException.
The exception message
[TestMethod, ExpectedException(typeof(AssertFailedException))]
public async Task AssertThrowsExceptionAsync_Failure_OldAssertion()
{
// arrange
static Task ThrowExceptionAsync() => throw new InvalidOperationException();
Func<Task> action = ThrowExceptionAsync;
// old assertion:
await Assert.ThrowsExceptionAsync<ArgumentException>(action);
}
Steps To Reproduce
using Assert.ThrowsException or Assert.ThrowsExceptionAsync and failing throws an AssertFailedException exception where the Message property contains "Exception Message: <the message>" and the "Stack Trace: at <stack-trace>"
Expected behavior
The exception's Message property should only include the fail message (like any other assertion method in mstest)