Skip to content

Capture additional exception details in the test output #3145

Closed
@drewburlingame

Description

@drewburlingame

When our applications throw exceptions, we capture additional context in the .Data property of the exceptions. We would like to include this context in the NUnit output to reduce the time spent combing through logs and stepping through the debugger.

I've created two options for capturing additional information from exceptions. https://github.com/drewburlingame/nunit/pull/1

  1. Capture the exception in a new ExceptionResult.Exception property.
    Pros:
    * A straightforward change.
    * It can be inspected by components for different purposes.
    Con:
    * Including the exception in the output of tests is more complicated, requiring an additional wrapper. The output will not be included as part of the default NUnit error message
  1. . Register a static delegate with ExceptionHelper.GetAdditionalDetails
    Pros:
    * A straightforward change.
    * Very simple to use
    * Context is included with the exception message, making it easier to correlate.
    Cons:
    * Doesn't fit with NUnit pattern of providing extensibility points via interfaces
    * Global to the app domain. Cannot be enabled only for select fixtures. This isn't an issue for our use case but I assume there are cases where this may be an issue.

Would either of these be acceptable solutions? If not, do you have recommendations for how you'd like to see it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions