3

I have a doubt regarding code coverage.

Consider the below scenario,

If I am having the method Sample() with some parameters and I wrote say example 10 test cases for that method.

While running code coverage, if a part of a code (say for example an if condition) is still not covered.

So if I am going to cover that if condition by writing new test case,

  • I can able to cover that code by using valid parameters alone(Using any one of an already existing test case).

And my doubt is,

Is that single test case is sufficient for that uncovered code? else I have to cover the code by repeating all the existing 10 test cases of that method?

Praveen
  • 831
  • 7
  • 15

1 Answers1

1

Code coverage 100% alone is not easy task to get.

By your example, it depends on you context(functionality) - it could be two separate scenarios. One is that, by white box testing, you have two existing paths - IF = TRUE or FALSE. Then given set of parameters generate others path inside you function, but if you function is about validation and all you test cases for given scenario tests same result (valid/invalid set of parameters) the expected result is same for all cases. But if you mix success and failure then should be separate.

timiTao
  • 1,417
  • 3
  • 20
  • 34