How to make SonarQube recognize NSubstitute assertions?

We are running into issues with the rule: C#: Tests should have assertions

Which states the following frameworks as supported:

  • MSTest
  • NUnit
  • XUnit
  • FluentAssertions

But we happen to use NSubstitute with patterns like this (example code):

[TestMethod]
void Test()
{
    // Arrange
    var calculator = Substitute.For<ICalculator>();

    // Act
    calculator.Add(1, 2);

    // Assert
    calculator.Received().Add(1, Arg.Any<int>());
}

The rule is really good, so I don’t want to disable it, nor do I want to manually fix every test case which uses the NSubstitute assertions.

What is our best approach here?

Thanks

welcome to the community, @run!

I added NSubstitute to #1353 thanks for the suggestion

Thank you!

Any idea (roughly), when this might be supported?

No.

The main priority for the rest of this year is to add support for the new C#8 features and to add some more rules to the analyzer. We might include it in the rules sprint, but the decision would be taken later in the year.

hi @run, this has been released in SonarCSharp 8.0