Edit on GitHub

xUnit1002 Error

Test methods cannot have multiple Fact or Theory attributes

Cause

A test method has multiple Fact or Theory attributes.

Reason for rule

A test method only needs one Fact or Theory attribute.

How to fix violations

To fix a violation of this rule, remove all but one of the Fact or Theory attributes.

Examples

Violates

using Xunit;

public class xUnit1002
{
    [Fact, Theory]
    public void TestMethod()
    { }
}

Does not violate

using Xunit;

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

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