I've got a little Problem.(at unittesting) - I unittest a class where methods raises exceptions. The structure is:
public bool DoA()
{
ThrowException();
return true;
}
public void DoB()
{
ThrowException();
}
private static void ThrowException()
{
throw new NotSupportedException();
}
The result from the CodeCoverage is not 100% - the return statement and the closing curly bracket from DoA() and the closing curly bracket from Do()B are not under the codeCoverage(because they not reached). I know, thats not really important for the unittest because i still checked the functionality but just for me - its possible and how i reach the full CodeCoverage? Maybe through exclude? (possible change the testcode / program code)
You can't reach the return true part of you code, so you can remove it. It is bad to have unreachable code in your projects. Or because the function DoA() is not finished, you can use: [ExcludeFromCodeCoverage]
[ExcludeFromCodeCoverage]
public bool DoA()
{
ThrowException();
return true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With