Bird
0
0

A test script has this code:

medium📝 Debug Q14 of 15
Testing Fundamentals - Why Software Testing Matters
A test script has this code:
def test_divide():
    result = 10 / 0
    assert result == 0
What is the main problem with this test?
AAssertion is incorrect because 10/0 equals 10
BDivision by zero causes an error before assertion
CTest will always pass because result is zero
DNo problem; test runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Identify the operation causing error

    Dividing 10 by zero raises a ZeroDivisionError before assertion runs.
  2. Step 2: Understand impact on test execution

    Because of the error, the test stops and does not reach the assertion, causing failure.
  3. Final Answer:

    Division by zero causes an error before assertion -> Option B
  4. Quick Check:

    ZeroDivisionError stops test early [OK]
Quick Trick: Check for runtime errors before assertions [OK]
Common Mistakes:
  • Assuming assertion runs despite error
  • Thinking 10/0 equals 10
  • Believing test passes without error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Testing Fundamentals Quizzes