Bird
0
0

Given this Python test code snippet:

medium📝 Predict Output Q4 of 15
Testing Fundamentals - Why Software Testing Matters
Given this Python test code snippet:
def test_addition():
    result = 3 + 4
    assert result == 7

What will be the test result when run?
ATest is skipped automatically
BTest fails because 3 + 4 equals 8
CTest raises a syntax error
DTest passes because 3 + 4 equals 7
Step-by-Step Solution
Solution:
  1. Step 1: Calculate the expression

    3 + 4 equals 7, so result is 7.
  2. Step 2: Check the assertion

    The assertion checks if result == 7, which is true, so test passes.
  3. Final Answer:

    Test passes because 3 + 4 equals 7 -> Option D
  4. Quick Check:

    Assertion true means test passes [OK]
Quick Trick: If assertion is true, test passes [OK]
Common Mistakes:
  • Miscomputing 3 + 4
  • Confusing assertion failure
  • Thinking syntax error occurs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Testing Fundamentals Quizzes