How do I get the stacktrace and error message from MSTest?
When I was using NUnit 3.x I was able to get both the stack trace and the error message using the following in my function [TearDown]
:
var stackTrace = TestContext.CurrentContext.Result.StackTrace;
var errorMessage = TestContext.CurrentContext.Result.Message;
So if I add an exception message to my assertion (i.e. Assert.AreEqual("A", "B", "A is not equal to B");
, I can access this error message and inject it into my report using the above variable var errorMessage
.
I have not yet been able to find a comparable way to access these values in MSTest, and the variable TestContext
for my tests does not contain any available values associated with these messages outside of checking if the test passed or failed through TestContext.CurrentTestOutcome
.
Is there a way to get this information from MSTest working?
source to share
No one has answered this question yet
Check out similar questions: