Complete the code to define a test method in Ruby using Minitest.
def [1]_test assert_equal(4, 2 + 2) end
The test method name should start with test_ followed by a descriptive name. Here, test_addition clearly describes the test.
Complete the code to write a failing test first in TDD.
def test_[1] assert_equal(5, add(2, 2)) end
The test is supposed to fail first in TDD. Since add(2, 2) should be 4, expecting 5 makes the test fail.
Fix the error in the test assertion to correctly check the output of the add method.
def test_addition assert_equal([1], add(2, 3)) end
The sum of 2 and 3 is 5, so the expected value in assert_equal should be 5.
Fill both blanks to complete the TDD cycle: write a failing test, then implement the method.
def test_[1] assert_equal(9, [2](4, 5)) end def [2](a, b) a + b end
The test method and the method under test must have matching names. Here, test_add tests the add method.
Fill all three blanks to complete a TDD example: write a test, implement the method, and run the test.
def test_[1] assert_equal([2], [3](3, 7)) end def [3](x, y) x + y end
The test method test_sum checks the add method, expecting 10 as the sum of 3 and 7.