[temp] Pages 144-6: Test::Unit Framework - Assertions == Expected results (part I)
Listen to this article.
Value: Low
Level: Easy
Summary:
The Test::Unit framework gives you: a way of expressing individual tests, a framework for structuring the tests, flexible ways of invoking the tests. Rather than have you write series of individual if statements in your tests, Test::Unit provides a series of assertions that achieve the same thing. Although a number of different styles of assertion exist, they all follow basically the same pattern. Each assertion
gives you a way of specifying a desired result or outcome and a way of passing in the
actual outcome. If the actual doesn't equal the expected, the assertion outputs a nice
message and records the fact as a failure.
Memo:
Example:
require 'roman'
require 'test/unit'
class TestRoman < Test::Unit::TestCase
def test_simple
assert_equal("i", Roman.new(1).to_s)
assert_equal("ix", Roman.new(9).to_s)
end
end
Reported errata (at 10/17/06 14:17:18 PDT): 0
Errata I found: 0
My suggestions to the author: 0
Doubts: 1
* Example code not understood
Level: Easy
Summary:
The Test::Unit framework gives you: a way of expressing individual tests, a framework for structuring the tests, flexible ways of invoking the tests. Rather than have you write series of individual if statements in your tests, Test::Unit provides a series of assertions that achieve the same thing. Although a number of different styles of assertion exist, they all follow basically the same pattern. Each assertion
gives you a way of specifying a desired result or outcome and a way of passing in the
actual outcome. If the actual doesn't equal the expected, the assertion outputs a nice
message and records the fact as a failure.
Memo:
Example:
require 'roman'
require 'test/unit'
class TestRoman < Test::Unit::TestCase
def test_simple
assert_equal("i", Roman.new(1).to_s)
assert_equal("ix", Roman.new(9).to_s)
end
end
Reported errata (at 10/17/06 14:17:18 PDT): 0
Errata I found: 0
My suggestions to the author: 0
Doubts: 1
* Example code not understood
0 Comments:
Post a Comment
<< Home