Skip to content

Instantly share code, notes, and snippets.

@bradwilson
Created August 18, 2020 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradwilson/476c398dc7f187904fa0d5c7bd2447bf to your computer and use it in GitHub Desktop.
Save bradwilson/476c398dc7f187904fa0d5c7bd2447bf to your computer and use it in GitHub Desktop.
Skip attribute: enable or no?
public class SampleTests
{
public bool SomeCondition => ...;
[Fact]
public void MySkipWhen()
{
Assert.SkipWhen(SomeCondition, "This is dynamically skipped when SomeCondition is true");
}
[Fact]
public void MySkipUnless()
{
Assert.SkipUnless(SomeCondition, "This is dynamically skipped when SomeCondition is false");
}
}
public class SampleTests
{
public bool SomeCondition => ...;
[Fact(
Skip = "This is dynamically skipped when SomeCondition is true",
SkipWhen = nameof(SomeCondition)
)]
public void MySkipWhen() { }
[Fact(
Skip = "This is dynamically skipped when SomeCondition is false",
SkipUnless = nameof(SomeCondition)
)]
public void MySkipUnless() { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment