I'm new to code coverage, and I'm trying to get my unit tests to cover% 100 of my code.
My first question is: is this possible / possible?
My second, more specific question: I have the following method:
public bool Clear()
{
try
{
this.Frames.Clear();
this.ControlGroups.Clear();
this.DisplayGroups.Clear();
return true;
}
catch (Exception ex)
{
Milltown.MTCore.mtException mtEx = new Milltown.MTCore.mtException((int)PFExceptions.Exception_Hidden_FuctionLevel, ex,
PFCommonVariables.ApplicationPlatform, PFCommonVariables.ApplicationDataSource, "PFSystem:Clear");
return false;
}
}
My unit test for this method:
Assert.IsTrue(MySystem.Clear());
Assert.AreEqual(0,MySystem.Frames.Count);
Assert.AreEqual(0,MySystem.ControlGroups.Count);
Assert.AreEqual(0, MySystem.DisplayGroups.Count);
The code coverage shows that I cover the lines inside the try block, but not the catch block. How can I cover code in catch blocks?
source
share