Minitest, a testing framework included with Ruby, is used to validate that our code behaves as expected under various conditions.
`
calculator.rb
class Calculator
def add(a, b)
a + b
end
end
tests/test_calculator.rb
require 'minitest/autorun'
require './calculator'
class TestCalculator < Minitest::Test
def test_addition
calculator = Calculator.new
assert_equal 4, calculator.add(2, 2), "Addition method failed"
end
end
`
Top comments (0)