S2699: False Positive with C# and Xunit for Unit Tests

SonarQube Version: 8.1.0.31237
Xunit Version: 2.4.1

We just upgraded our Sonar server to 8.1 and started getting some false positives around S2699: Tests should include assertions.

We have written some of our tests to do the assertions in another method to cut down on code duplication. It appears that the scanner doesn’t check the methods called in the test for assertions.

Any ideas/suggestions?

[Fact]
        public void Test1()
        {
            Test_BasicData(false, false, "ConfigTests");
        }

public void Test_BasicData(bool test1, bool test2, string paramTest)
{
// assertions here
}

Thanks!
Russell

hi @Russell_Miller

This is a known problem. We have a ticket to address this issue, which you can follow : https://github.com/SonarSource/sonar-dotnet/issues/2713

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.