We have implemented few such test cases and SonarQube expects at least one assertion for such test case. This assertion is not needed from the test case point of view, since it works correctly

Template for a good bug report, formatted with Markdown:

  • versions used - 7.9
  • error observed - We use Moq library for helping in unit tests. Moq has concept of MockSequence which supports specifying in which sequence functionality must be called. If sequence is not followed, test case fails. We have implemented few such test cases and SonarQube expects at least one assertion for such test case. This assertion is not needed from the test case point of view, since it works correctly.

Please help.

Hi @prince_raj ,

You can customise a Quality Profile in your target programming language, deactivate the rule that’s giving you trouble, and assign this customised QP to the project(s) that use Moq.

You can also customise when this rule should be ignored if you mix Moq with standard assertions. Have a look at Narrowing the Focus.

Best regards,
Daniel