
174
10
章 テストを整理する〜混沌の中から法則を見つけ出す〜
10
.
2
分離されたテストの美しさ
11
1
class RectangleTest < MiniTest::Test
def setup
@length = 3.0
@width = 4.0
end
def test_area
assert_equal(12, Rectangle.area(@length, @width))
end
def test_perimeter
assert_equal(14, Rectangle.perimeter(@length, @width))
end
end
1つの対象だけをテストする
長方形に関するテストだけを実施
必要なデータだけを定義
...