Challenge - 5 Problems
Minitest Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Minitest assertion?
Consider the following Minitest code snippet. What will be the result when this test runs?
Ruby
require 'minitest/autorun' class TestExample < Minitest::Test def test_sum sum = 2 + 3 assert_equal(5, sum) end end
Attempts:
2 left
💡 Hint
Check what assert_equal expects and what sum is.
✗ Incorrect
The assertion checks if sum equals 5. Since 2 + 3 is 5, the test passes without errors.
❓ Predict Output
intermediate2:00remaining
What error does this Minitest assertion raise?
What error will this test produce when run?
Ruby
require 'minitest/autorun' class TestExample < Minitest::Test def test_truth assert(false, "This should fail") end end
Attempts:
2 left
💡 Hint
assert expects a true value to pass.
✗ Incorrect
assert(false) fails and raises Minitest::Assertion with the given message.
🔧 Debug
advanced2:30remaining
Why does this Minitest assertion fail unexpectedly?
Examine the test below. Why does the assertion fail even though the values look equal?
Ruby
require 'minitest/autorun' class TestExample < Minitest::Test def test_array_equality a = [1, 2, 3] b = [1, 2, 3.0] assert_equal(a, b) end end
Attempts:
2 left
💡 Hint
Check the types of elements inside the arrays.
✗ Incorrect
3 (Fixnum) and 3.0 (Float) are different types and not equal, so the assertion fails.
📝 Syntax
advanced2:00remaining
Which option causes a syntax error in this Minitest test?
Identify the option that will cause a syntax error when running this test code.
Ruby
require 'minitest/autorun' class TestExample < Minitest::Test def test_truth assert true end end
Attempts:
2 left
💡 Hint
Check if all method definitions are properly closed.
✗ Incorrect
Option B is missing the closing 'end' for the method, causing a syntax error.
🚀 Application
expert2:30remaining
How many assertions are run in this Minitest test method?
Given the following test method, how many assertions will Minitest count when this test runs?
Ruby
require 'minitest/autorun' class TestExample < Minitest::Test def test_multiple_asserts assert_equal(4, 2 + 2) assert(3 > 1) assert_nil(nil) end end
Attempts:
2 left
💡 Hint
Count each assert or assert_equal call as one assertion.
✗ Incorrect
Each assert, assert_equal, and assert_nil counts as one assertion, so total is 3.