0

I have a confusion regarding the method coverage calculation. consider the code below.

function A (n1)
{
if (n>1)
    C();
else
    print n1;
} 

Now, My test case calls A() as A(1) It means function A will not call function C. Now, is method coverage 50% or 100%?

sheldon cooper
  • 455
  • 2
  • 8
  • 22
  • It's 50%, since C is never called. Why would you think it would be 100%? – Dave Schweisguth May 11 '16 at 05:49
  • Because i read at one website that even if a single statement of a method is executed, it would be considered as covered. By that definition, it should be 100 % as function c is part of A – sheldon cooper May 11 '16 at 09:31
  • No, it only counts if execution enters the body of the method. Merely referring to the declaration from code that's never executed doesn't count. – Dave Schweisguth May 11 '16 at 14:44

0 Answers0