When I've used NUnit 3.x, I've been able to obtain both stack trace and error message using the following in my [TearDown] function:
var stackTrace = TestContext.CurrentContext.Result.StackTrace;
var errorMessage = TestContext.CurrentContext.Result.Message;
Therefore, if I add an exception message to my assertion (i.e. Assert.AreEqual("A", "B", "A is not equal to B");, I can access that error message and input it into my report via the var errorMessage variable above.
I've yet to find a comparable way to access these values in MSTest, and the TestContext variable for my tests do not seem to contain any accessible values related to these messages outside of checking if the test passed or failed via TestContext.CurrentTestOutcome.
Is there a way to obtain this information from MSTest runs?
Aucun commentaire:
Enregistrer un commentaire