No, I do not believe that you can configure VS to show it in a different way. The IDE shows the first line of the exception message, and the text of the full text has a newline, so you need to go to the details to see all of this.
However, you can use the MSTest framework to display your own messages.
MS Test Assertions are implemented by throwing exceptions. All MS Test Assert
functions throw exceptions thrown from UnitTestAssertException
. Visual Studio has special handling for these kinds of exceptions.
For example: if you write this test:
[TestMethod] public void AllAboard() { throw new AssertFailedException("Failboat"); }
AssertFailedException
is the standard base class for most other assertion failures.
You will notice that VS2010 does not print the message “test threw an exception”, instead it just prints “Failboat”.
Now, what you can do is surround your tests with things that AssertFailedException
ordinary exceptions into an AssertFailedException
, and then you can print any messages you like.
[TestMethod] public void TestStuff() { try { string o = null; // pretend this came from some real code var x = o.Split(new[] { ',' }); // this will throw NullRefException } catch (Exception e) { throw new AssertFailedException(e.Message, e); } }
Of course, I would not recommend doing this ... it's verbose, and most importantly, you will lose the call stack ... but hey, now you have another tool in your toolbox
source share