Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print full exception details in error message #2368

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ymarcov
Copy link

@ymarcov ymarcov commented Aug 25, 2021

When a test fails, print full exception details.

This provides a crucial stop-gap for many developers needing good log messages from CI test runs (in our case an important service within Microsoft).

@dnfadmin
Copy link

dnfadmin commented Aug 25, 2021

CLA assistant check
All CLA requirements met.

@bradwilson
Copy link
Member

First, this isn't a solution for the original problem. You've changed things unrelated to AssemblyRunner by modifying the output from our in-box runners. The original linked issue was specifically related to the fact that AssemblyRunner doesn't sufficiently dive into the failure details, and has nothing to do with the in-box runners.

In addition, I don't particularly like the fact that the resulting output isn't as nicely formatted (and you've removed a valuable feature wherein we eliminate any stack frame which comes from xUnit.net itself). Comparisons:

Current:

image

Your PR:

image

So I believe this PR does not adequately solve the issue that's linked (and I don't think any of the code you've added would actually be necessary to fix the original issue).

@ymarcov
Copy link
Author

ymarcov commented Aug 30, 2021

The main point is to get the output of exception.ToString(), as it already contains the entire exception tree. From what I saw, at the point where the error details reach the AssemblyRunner those details are already lost, as they've been extracted into Message, Stacktraces, etc.

To pass them along I had to go back to the point of capture, which is deeper inside.

Calling exception.ToString() also means that formatting is delegated, and because at that point we're dealing with free-text, filtering it manually is a bit precarious.

Perhaps a more elegant solution would be to implement Stacktraces as a tree rather than a list. That would allow us to represent the exception tree propertly, as well as format it accordingly. Another equivalent option is to add some textual metadata as prefixes to the stacktrace strings that represents the location of the exception in the hierarchy (e.g. 0:2:1 would mean Root->3rd sibling->2nd sibling), that we could format an indented hierarchy out of in the output. This is of course a very contrived exception tree, but I think it does need to be solved for the general case, just as exception.ToString() does.

@bradwilson
Copy link
Member

@ymarcov
Copy link
Author

ymarcov commented Sep 22, 2021

@bradwilson Oh nice. I see that xunit.v3.runner.utility already depends on xunit.abstractions. So if I understand correctly, I could simply utilize IFailureInformation to print out the full hierarchy that's already been captured at that point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants