Edit on GitHub

xUnit2004   v2 v3   Warning

Do not use equality check to test for boolean conditions

Cause

A violation of this rule occurs when:

Reason for rule

It’s more readable to use Assert.True or Assert.False instead.

How to fix violations

For Equal and StrictEqual

For NotEqual and NotStrictEqual

Examples

Violates

using Xunit;

public class xUnit2004
{
    [Fact]
    public void TestMethod()
    {
        var result = 2 + 2;

        Assert.Equal(true, result > 3);
    }
}

Does not violate

using Xunit;

public class xUnit2004
{
    [Fact]
    public void TestMethod()
    {
        var result = 2 + 2;

        Assert.True(result > 3);
    }
}
Copyright © .NET Foundation. Contributions welcomed at https://github.com/xunit/xunit/tree/gh-pages.