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

Support AggregateExceptions? #31

Open
DennisDyallo opened this issue Apr 4, 2024 · 7 comments
Open

Support AggregateExceptions? #31

DennisDyallo opened this issue Apr 4, 2024 · 7 comments

Comments

@DennisDyallo
Copy link

Any chance for support of AggregateExceptions could be added easily?

@AArnott
Copy link
Owner

AArnott commented Apr 4, 2024

Can you clarify? What exactly would you like to see?

@DennisDyallo
Copy link
Author

Hi @AArnott and thanks for the quick response!
Well, I'm using xUnit 2.6.1 and inheriting IClassFixtures in my tests. The IClassFixture throws an AggregateException instead of the underlying custom exception that I wish to skip the test on receiving.

I mean I could go [SkippableTheory(typeof(AggregateException))] instead of [SkippableTheory(typeof(CustomException))], but that will Skip the test for the wrong reasons.

If SkippableFact could detect the exceptions inside of the AggregateExceptions it would be able to determine to Skip the test. I don't know if the xUnit API allows that as things are.

Any ideas?

image

@AArnott
Copy link
Owner

AArnott commented Apr 4, 2024

Thanks. That helps a lot. Can you confirm that the only exception within AggregateException is the skip exception, such that we can skip in only that condition? Or is it important that we skip if any one exception inside the aggregate is a skip exception, even if other failures are also present?

@DennisDyallo
Copy link
Author

For my usecase, I'd be happy to simply Skip as soon as a predetermined SkipException is detected. That's because as soon as I detect there's a skip exception thrown, I don't care about the rest.

And to answer your first question: There was actually another exception in the AggregateException:
Xunit.Sdk.TestClassException: The following constructor parameters did not have matching fixture data: MyFixtureClass myFixtureParam. Exception doesn't have a stacktrace

Seems to come from here:
https://github.com/xunit/xunit/blob/21e2eef5a46138e09cd90c8a93d644d5c0d3496a/src/xunit.v3.core/Sdk/v3/Runners/TestClassRunner.cs#L68

@AArnott
Copy link
Owner

AArnott commented Apr 5, 2024

Would you be interested in contributing the PR?

@DennisDyallo
Copy link
Author

Yes but what's the plan on .net6, is the upgrade planned? And this package, is eventually merging into xUnit?

@AArnott
Copy link
Owner

AArnott commented Apr 5, 2024

There are no plans to merge this package into xunit. But xunit v3 might be adding its own skippable support, which would make this package obsolete.
As for .NET 6, this package already works for .NET 6 targeting test projects.

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

No branches or pull requests

2 participants