Bird
0
0

Which of the following is the correct syntax to write a test method in Minitest using assert style?

easy📝 Syntax Q12 of 15
Ruby - Testing with RSpec and Minitest
Which of the following is the correct syntax to write a test method in Minitest using assert style?
Afunction test_example() { assert_equal(5, 2 + 3); }
Bdef test_example; assert_equal 5, 2 + 3; end
Ctest 'example' do; assert_equal 5, 2 + 3; end
Dtest_example() { assert_equal 5, 2 + 3 }
Step-by-Step Solution
Solution:
  1. Step 1: Identify Ruby method syntax for Minitest

    In Minitest, test methods start with def test_... and end with end.
  2. Step 2: Check the assert usage inside the method

    assert_equal expected, actual is used correctly inside the method.
  3. Final Answer:

    def test_example; assert_equal 5, 2 + 3; end -> Option B
  4. Quick Check:

    Ruby test method syntax = C [OK]
Quick Trick: Test methods start with def test_ and end with end [OK]
Common Mistakes:
  • Using non-Ruby syntax like function or braces
  • Using test do blocks which belong to other frameworks
  • Missing def or end keywords

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes