Branch coverage measures whether tests execute the alternative branches in a program’s control flow. Each if, while, and similar decision creates different preconditions to test. section 9.1.3
Use it to find untested paths, often associated with edge cases. Perfect coverage still does not prove that the code works; it only proves that those parts ran. section 9.1.3
Conditional and loop branches
For has_long_words, tests should exercise non-string and string inputs, an input containing a word longer than ten characters, and inputs where no word meets that condition. section 9.1.3
Listing 9.1. A function with conditionals and a loop
def has_long_words(sentence):
if isinstance(sentence, str): #1
sentence = sentence.split(' ')
for word in sentence: #2
if len(word) > 10: #3
return True
return False #4
Inspect the compact function to identify its conditional, loop, early return, and final return paths. section 9.1.3


