Bird
0
0

Why might a test double cause a test to pass even if the real object would fail?

hard📝 Conceptual Q10 of 15
Ruby - Testing with RSpec and Minitest

Why might a test double cause a test to pass even if the real object would fail?

ABecause doubles run the real code internally
BBecause the double only simulates behavior and may not reflect real logic
CBecause doubles always raise errors on method calls
DBecause doubles connect to the real database
Step-by-Step Solution
Solution:
  1. Step 1: Understand test double behavior

    Doubles simulate methods and return preset values without running real logic.
  2. Step 2: Identify why tests might pass incorrectly

    Since doubles don't execute real code, they can hide bugs that real objects would reveal.
  3. Final Answer:

    Because the double only simulates behavior and may not reflect real logic -> Option B
  4. Quick Check:

    Doubles simulate, not execute real code [OK]
Quick Trick: Doubles simulate behavior; real logic may differ [OK]
Common Mistakes:
  • Thinking doubles run real code
  • Assuming doubles always error
  • Believing doubles connect to databases

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes