Table of Contents
  v2 v3   Error

xUnit9009

"Fact methods cannot be generic"

Cause

A violation of this rule occurs when a test method decorated with [Fact] has been declared as generic.

Reason for rule

[Fact] methods cannot be generic. They have no data over which to close the open-generic.

How to fix violations

To fix a violation of this rule, remove the generic.

Examples

Violates

using Xunit;

public class xUnit9009
{
    [Fact]
    public void TestMethod<T>()
    { }
}

Does not violate

using Xunit;

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