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

FailedTestNodeStateProperty should include the ability to report without an exception #2536

Open
bradwilson opened this issue Mar 10, 2024 · 5 comments
Labels
Area: Testing Platform Belongs to the Microsoft.Testing.Platform core library Type: Feature

Comments

@bradwilson
Copy link

The constructors for FailedTestNodeStateProperty do not include the ability to provide extended error information outside of an Exception object.

xUnit.net's error reporting APIs do not include Exception objects. Given our split between runners and execution environment, it may not even be possible for us to re-create instances of the original Exception classes since the types in question may not be available inside the runner infrastructure.

Please provide an alternative way to report errors that allow capturing the essence of Exception without depending on specific instances.

@MarcoRossignoli
Copy link
Contributor

Do you mean something similar to

public class ExceptionInformation(string exceptionMessage, string? stackTrace = null);

Feel free to propose something.

@bradwilson
Copy link
Author

Based on https://github.com/microsoft/testfx/blob/main/docs/mstest-runner-protocol/001-protocol-intro.md#test-node I would say an overloaded constructor for FailedTestNodeStateProperty that would accept a message and stackTrace parameter makes the most sense.

@Evangelink
Copy link
Member

In case it helps, this is the custom exception I have created to map some failed tests report from VSTest object model to the new platform:

internal sealed class VSTestException : Exception
{
    public VSTestException(string? message, string? stackTrace)
        : base(message)
    {
        StackTrace = stackTrace;
    }

    public override string? StackTrace { get; }
}

used as

case TestOutcome.Failed:
    testNode.Properties.Add(new FailedTestNodeStateProperty(new VSTestException(testResult.ErrorMessage, testResult.ErrorStackTrace)));
    break;

@bradwilson
Copy link
Author

Since there doesn't appear to be any type reporting on the exceptions, this seems reasonable, albeit hard to discover for general usage. 😄

@bradwilson
Copy link
Author

bradwilson commented Mar 11, 2024

Also, it does not appear that the system can handle inner exceptions, I presume for simplicity's sake. How would expect inner exceptions to be reported in this system? We have a "format" that we use to report messages and stack traces when there are inner exceptions, which of course fit into "strings" just fine, but in the case of stack traces they aren't necessarily guaranteed to be "one stack frame per line" since some of the lines describe the relationships. Is that acceptable in the new model?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Testing Platform Belongs to the Microsoft.Testing.Platform core library Type: Feature
Projects
None yet
Development

No branches or pull requests

3 participants