microsoft / testfx

MSTest framework and adapter
MIT License
697 stars 250 forks source link

Properties for TextContext to get info from Test details summary #3228

Open adrozdowski opened 1 month ago

adrozdowski commented 1 month ago

Summary

TextContext class includes 2 new properties. TextContext.StackTrace and TextContext.Message (Exception).

Background and Motivation

Hi. I highly need properties for TestContext to get Error message and Stack trace. I am making a custom report and now getting this data is alomost impossible

Proposed Feature

When I use TextContext.Message a message from red rectangle will be returned. When I use TextContext.StackTrace a stack trace from green rectangle will be returned. image

Alternative Designs

It is the same feature like NUnit 3.x has https://stackoverflow.com/questions/43236826/how-to-obtain-the-stacktrace-and-error-message-from-mstest-run:

var stackTrace = TestContext.CurrentContext.Result.StackTrace; var errorMessage = TestContext.CurrentContext.Result.Message;

Evangelink commented 1 month ago

Hi @Adrian,

Thanks for the request. It would indeed makes sense to be able to retrieve more information about the test execution.