Edit on GitHub

xUnit1005   v2 v3   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

using Xunit;

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

Does not violate

using Xunit;

public class xUnit1005
{
    [Fact]
    public void TestMethod()
    { }
}
using Xunit;

public class xUnit1005
{
    [Theory, InlineData(1)]
    public void TestMethod(int _)
    { }
}
Copyright © .NET Foundation. Contributions welcomed at https://github.com/xunit/xunit/tree/gh-pages.