Home > other >  How many test cases would i need to test all branches?
How many test cases would i need to test all branches?

Time:12-11

the test method is the following

def testArrayLength(array):# array passed through
  int length = len(array); //get number of chars in the container
   if(length > 20)
     return 1
   if(length > 1)
     return 0
  if(length == 0)
     return -1

would there be minimum of three test cases to have 100% branch coverage?

CodePudding user response:

a test set to achieve 100% branch coverage, every branching point in the code must have been taken in each direction, at least once.

thanks

CodePudding user response:

You would probably want to have a test case for every possible outcome of your function. In your case, your possible outcomes are 1, 0, and -1.

So yes, you need 3 test cases for 100% coverage of this function.

  • Related