Bird
0
0

Consider this code snippet for a simple test:

medium📝 Predict Output Q13 of 15
Testing Fundamentals - Why Software Testing Matters
Consider this code snippet for a simple test:
def test_sum():
    result = sum([1, 2, 3])
    assert result == 6
    print('Test passed')
What will be the output when this test runs?
AAssertionError
BNo output
C6
DTest passed
Step-by-Step Solution
Solution:
  1. Step 1: Understand the sum function and assertion

    sum([1, 2, 3]) equals 6, so the assertion result == 6 is true.
  2. Step 2: Check what happens after assertion

    Since assertion passes, print('Test passed') runs and outputs 'Test passed'.
  3. Final Answer:

    Test passed -> Option D
  4. Quick Check:

    Correct sum and assertion = print message [OK]
Quick Trick: If assert passes, print statement runs [OK]
Common Mistakes:
  • Thinking assertion fails and raises error
  • Expecting sum function to print result
  • Assuming no output without explicit print

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Testing Fundamentals Quizzes