Test methods should not be skipped
Tests should not be skipped long term. This analyzer highlights skipped tests for better visibility.
Skipping tests should be considered a temporary mechanism, and as such, tests which are skipped are highlighted so they’re easier to see and to allow the developer to fix the issue.
For v3 test projects, using SkipWhen
or SkipUnless
suppresses this analyzer, since that’s used to conditionally skip tests based on the testing environment.
To fix a violation of this rule, you will typically employ one of two strategies:
using Xunit;
public class xUnit1004
{
[Fact(Skip = "This is a flaky test")]
public void TestMethod() { }
}
using Xunit;
public class xUnit1004
{
[Fact]
public void TestMethod() { }
}
using System;
using Xunit;
public class xUnit1004
{
[Fact(Skip = "This test requires Windows",
SkipUnless = nameof(OperatingSystem.IsWindows),
SkipType = typeof(OperatingSystem))]
public void TestMethod() { }
}