I am new to code-coverage, and I am trying to get my unit tests to cover %100 of my code.
My first question is, is this possible/feasible?
My second, more specific question is, I have the following method:
/// <summary>
/// Clears frames, control groups, display groups
/// </summary>
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 is:
//System Clear Test
Assert.IsTrue(MySystem.Clear());
Assert.AreEqual(0,MySystem.Frames.Count);
Assert.AreEqual(0,MySystem.ControlGroups.Count);
Assert.AreEqual(0, MySystem.DisplayGroups.Count);
Code coverage shows that I am covering the lines inside the try block, but not the catch block. How can I cover the code in catch blocks?