[temp] Pages 143-4: Unit testing
Listen to this article.
Value: Low
Level: Easy
Summary:
Unit testing is running a program that calls part of your
application's code, get back some results, and then check the results
are what you expected. Various unit testing frameworks have emerged to
help structure the testing process. Ruby comes with one preinstalled,
Nathaniel Talbott's Test::Unit framework. Unit testing focuses on
small chunks (units) of code, typically individual methods or lines
within methods.
Memo: 0
Example:
Let's say we're testing a Roman number class. So far the code is
pretty simple: it just lets us create an object representing a certain
number and display that object in Roman numerals.
We could test this code by writing another program, like this.
require 'roman'
r = Roman.new(1)
fail "'i' expected" unless r.to_s == "i"
r = Roman.new(9)
fail "'ix' expected" unless r.to_s == "ix"
Reported errata (at 10/17/06 14:17:18 PDT): 0
Errata I found: 0
My suggestions to the author: 0
Doubts: 0
Level: Easy
Summary:
Unit testing is running a program that calls part of your
application's code, get back some results, and then check the results
are what you expected. Various unit testing frameworks have emerged to
help structure the testing process. Ruby comes with one preinstalled,
Nathaniel Talbott's Test::Unit framework. Unit testing focuses on
small chunks (units) of code, typically individual methods or lines
within methods.
Memo: 0
Example:
Let's say we're testing a Roman number class. So far the code is
pretty simple: it just lets us create an object representing a certain
number and display that object in Roman numerals.
We could test this code by writing another program, like this.
require 'roman'
r = Roman.new(1)
fail "'i' expected" unless r.to_s == "i"
r = Roman.new(9)
fail "'ix' expected" unless r.to_s == "ix"
Reported errata (at 10/17/06 14:17:18 PDT): 0
Errata I found: 0
My suggestions to the author: 0
Doubts: 0
0 Comments:
Post a Comment
<< Home