0
0
Testing Fundamentalstesting~10 mins

Branch coverage in Testing Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to illustrate the branches in an if-else statement for branch coverage.

Testing Fundamentals
if condition:
    execute_true_branch()
else:
    execute_[1]_branch()
Drag options to blanks, or click blank then click option'
Afalse
Btrue
Cpath
Ddecision
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to test the else branch
Assuming only the true branch matters
2fill in blank
medium

Complete the code to ensure branch coverage for a function with two conditions.

Testing Fundamentals
def check_values(a, b):
    if a > 0:
        return 'Positive'
    elif b [1] 0:
        return 'Non-positive b'
    else:
        return 'Other'
Drag options to blanks, or click blank then click option'
A>=
B!=
C<=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which only checks for zero
Using '!=' which excludes zero
3fill in blank
hard

Fix the error in the branch coverage test condition.

Testing Fundamentals
if score [1] 50:
    print('Pass')
else:
    print('Fail')
Drag options to blanks, or click blank then click option'
A<
B>=
C=>
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=>' which is a syntax error
Using '==' which only checks equality
4fill in blank
hard

Fill both blanks to create a branch coverage test for a nested condition.

Testing Fundamentals
if temperature [1] 0:
    if weather [2] 'snowy':
        action = 'Stay inside'
    else:
        action = 'Go outside'
Drag options to blanks, or click blank then click option'
A>
B==
C!=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<' for temperature
Using '!=' instead of '==' for weather
5fill in blank
hard

Fill all three blanks to complete a branch coverage test with a dictionary comprehension.

Testing Fundamentals
results = {test[1]: outcome for test, outcome in tests.items() if outcome [2] 'fail' and 'critical' [3] test}
Drag options to blanks, or click blank then click option'
A.upper()
B==
Cin
D.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using .upper() instead of .lower()
Using '!=' instead of '==' for outcome
Using '==' instead of 'in' for test name check