Edit on GitHub

xUnit1005 Warning

Fact methods should not have test data

Cause

A fact method has one or more attributes that provide test data.

Reason for rule

Unlike theory methods, fact methods do not have any parameters. Providing a fact method with test data is therefore pointless, as there is no way to actually pass that data to the test method.

How to fix violations

To fix a violation of this rule, either:

Examples

Violates

public class TestClass
{
    [Fact, InlineData(1)]
    public void TestMethod()
    {
    }
}

Does not violate

public class TestClass
{
    [Fact]
    public void TestMethod()
    {
    }

    [Theory, InlineData(1)]
    public void ParameterizedTestMethod(int arg)
    {
    }
}

How to suppress violations

#pragma warning disable xUnit1005 // Fact methods should not have test data
#pragma warning restore xUnit1005 // Fact methods should not have test data
Copyright © 2017 .NET Foundation. Contributions welcomed at https://github.com/xunit/xunit.analyzers.