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
Should FactAttribute
support SkipWhen
/SkipUnless
properties?
#2339
Comments
Since this is a discussion i'll add some thoughts I can find a use for this if similar to test data we could point it at a property or method which would calculate the result. With that assumption it could clean duplicated SkipWhen/SkipUnless at the top of methods if you have a bunch which are skipped on the same condition e.g. OS conditions. I'm assuming you could also wrap in your own fact that includes the SkipWhen/SkipUnless so it can be easier to find e.g. WindowsOnlyFact or whatever. |
Yeah, sorry, I started moving things around on the 3.0 work list and created this issue, but forgot to fill in the description. 😂 Yes, the idea would be that it would point to something which calculated whether to skip at discovery time, much like |
I like this proposal, but it would me much usable when we can calculate it real time. Something like https://github.com/AArnott/Xunit.SkippableFact. f. egz. [Fact]
[InlineData(true)]
[InlineData(false)]
public void TestSkipping(bool shouldSkip)
{
Assert.Skip(shouldSkip);//when true it breaks hiere with test result as Skipped
Assert.False(shouldSkip);//when false it should Success
} or something like that: [Fact(SkipWhenExceptionType = typeof(SkipException)]
[InlineData(true)]
[InlineData(false)]
public void TestSkipping(bool shouldSkip)
{
_ = !shouldSkip ?? throw new SkipException("Should skip this test")//when true it breaks hiere with test result as Skipped
Assert.False(shouldSkip);//when false it should Success
} |
@pawelhevy That's already implemented for v3: https://github.com/xunit/assert.xunit/blob/main/SkipAsserts.cs |
Proposed usage would be something like:
The text was updated successfully, but these errors were encountered: