Bird
0
0

What will be the output when running this Minitest code?

medium📝 Predict Output Q13 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_multiply
    assert_equal 15, 3 * 5
  end

  def test_fail
    assert_equal 10, 2 + 2
  end
end
A1 test passed, 1 test failed
BAll tests passed
CSyntax error
DNo tests run
Step-by-Step Solution
Solution:
  1. Step 1: Analyze each test method

    test_multiply checks if 3*5 equals 15 (true), test_fail checks if 2+2 equals 10 (false).
  2. Step 2: Determine test results

    One test passes, one test fails, so output shows 1 pass and 1 fail.
  3. Final Answer:

    1 test passed, 1 test failed -> Option A
  4. Quick Check:

    One true, one false test = 1 pass, 1 fail [OK]
Quick Trick: Check each assertion result to find pass/fail count [OK]
Common Mistakes:
  • Assuming all tests pass
  • Expecting syntax error without error
  • Thinking no tests run

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes