My code coverage has listed my custom exception as 0 test coverage. I am using MsTest,Moq and Fluentassertions. Is there an appropriate unit test for a custom exception?
Here is my Exception class
public class ConfigurationNotFoundException : Exception
{
public ConfigurationNotFoundException()
{
}
public ConfigurationNotFoundException(string message) : base(message)
{
}
public ConfigurationNotFoundException(string message, Exception innerException) : base(message, innerException)
{
}
protected ConfigurationNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
You could write a test which calls each constructor, to satisfy your code coverage tool. But you should determine what code needs testing yourself. If you want to have 100% coverage, go ahead and write a crummy unit test, but you are better off looking at why you write tests. Does adding a trivial unit test increase the quality of your code?
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