Bird
0
0

What will be the output when running this Minitest code?

medium📝 Predict Output Q4 of 15
Ruby - Testing with RSpec and Minitest
What will be the output when running this Minitest code?
require 'minitest/autorun'

class TestMath < Minitest::Test
  def test_sum
    assert_equal 5, 2 + 3
  end
end
A1 test, 1 failure
BNo tests run
CSyntax error
D1 test, 0 failures
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the test method

    The test checks if 2 + 3 equals 5, which is true.
  2. Step 2: Understand Minitest output

    Since the assertion passes, Minitest reports 1 test run with 0 failures.
  3. Final Answer:

    1 test, 0 failures -> Option D
  4. Quick Check:

    Passing assert_equal = 1 test, 0 failures [OK]
Quick Trick: Passing tests show 0 failures in output [OK]
Common Mistakes:
  • Assuming failure when assertion is true
  • Confusing syntax errors with test failures
  • Expecting no tests to run without reason

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes