Bird
0
0

Identify the error in this Minitest code snippet:

medium📝 Debug Q14 of 15
Ruby - Testing with RSpec and Minitest
Identify the error in this Minitest code snippet:
class MyTest < Minitest::Test
  def test_check
    assert_equal(4, 2 + 2
  end
end
ATest method name does not start with 'test_'
BIncorrect class inheritance from Minitest::Test
CMissing closing parenthesis in assert_equal call
Dassert_equal arguments are in wrong order
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of assert_equal call

    The line assert_equal(4, 2 + 2 is missing a closing parenthesis.
  2. Step 2: Verify other parts of the code

    Class inheritance and method name are correct, and argument order is correct (expected, actual).
  3. Final Answer:

    Missing closing parenthesis in assert_equal call -> Option C
  4. Quick Check:

    Syntax errors often from missing parentheses = A [OK]
Quick Trick: Count parentheses carefully in assert calls [OK]
Common Mistakes:
  • Ignoring missing parentheses causing syntax errors
  • Thinking test method name can be arbitrary
  • Confusing argument order in assert_equal

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes