I am running into a little trouble with my unit testing code and SonarQube.
I have the following simple test:
[TestMethod]
public void TestFormat_Null()
{
_sut.Format(null);
}
public void Format(IPhone phoneNumber)
{
if (phoneNumber == null) return;
FormatNumber(phoneNumber);
FormatAreaCode(phoneNumber);
FormatCountryCode(phoneNumber);
}
The requirement here is, that if null is passed in, the method will simply do nothing, since there is nothing to format and also not crash with an exception.
Now the problem we are getting is that our SonarQube complains, that this is a test without any Assertions.
Is there any better way to declare a test that tests for a method not doing anything or is this a case where the SonarQube warning should simply be ignored?