'\" t .\" Title: detest .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.75.2 .\" Date: 08/08/2010 .\" Manual: \ \& .\" Source: \ \& 3.1.1 .\" Language: English .\" .TH "DETEST" "1" "08/08/2010" "\ \& 3\&.1\&.1" "\ \&" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" detest \- Assertion testing library for Ruby .SH "SYNOPSIS" .sp \fBdetest\fR [\fIOPTIONS\fR] (\fIFILE\fR|\fIGLOB\fR)\&... .SS "Command" .sp Loads the given \fIFILE\fR paths and paths matched by the given \fIGLOB\fR patterns into Ruby, then executes all tests defined therein, and finally terminates with an exit status reflecting the number of errors and assertion failures (up to a maximum of 255 to avoid 8\-bit unsigned integer overflow) that occurred\&. .SS "Options" .PP \fB\-d\fR, \fB\-\-debug\fR .RS 4 Launch interactive debugger upon assertion failures\&. .RE .PP \fB\-h\fR, \fB\-\-help\fR .RS 4 Display this manual and exit\&. .RE .PP \fB\-v\fR, \fB\-\-version\fR .RS 4 Print version number and exit\&. .RE .SS "Examples" .sp Execute the foo_test\&.rb and bar_test\&.rb files in the current directory: .sp .nf detest foo_test\&.rb bar_test\&.rb .fi .sp Execute all *_test\&.rb files inside the test/ directory: .sp .nf detest \'test/*_test\&.rb\' .fi .sp Execute all *_test\&.rb files inside or beneath the test/ directory: .sp .nf detest \'test/**/*_test\&.rb\' .fi .sp Execute all foo_test\&.rb and bar_test\&.rb files inside or beneath the test/ directory: .sp .nf detest \'test/**/{foo,bar}_test\&.rb\' .fi .SH "DESCRIPTION" .sp Detest is an assertion testing library for the Ruby programming language\&. It features a simple assertion vocabulary, instant debuggability of failures, and flexibility in composing tests\&. .SS "Features" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Only 8 mnemonic method names to remember: .sp \fBT\fRrue, \fBF\fRalse, \fBN\fRil, \fBE\fRrror, \fBC\fRatch, \fBS\fRhare, \fBI\fRnform, \fBD\fRescribe .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Lets you debug assertion failures interactively\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Lets you nest tests, assertions, and execution hooks\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Maintains a detailed report of assertion failures\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Implemented in 436 lines of pure Ruby\&. .RE .SS "Resources" .PP Project website .RS 4 http://snk\&.tuxfamily\&.org/lib/detest/ .RE .PP Announcements feed .RS 4 http://snk\&.tuxfamily\&.org/lib/detest/ann\&.xml .RE .PP API documentation .RS 4 http://snk\&.tuxfamily\&.org/lib/detest/api/ .RE .PP Source code (browse online, download, or checkout) .RS 4 http://github\&.com/sunaku/detest .RE .PP Issue tracker (report bugs, request features, get help) .RS 4 http://github\&.com/sunaku/detest/issues .RE .SH "INSTALL" .SS "Prerequisites" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} [Ruby] 1\&.8\&.6 or newer\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} [RubyGems] 1\&.3\&.6 or newer\&. .RE .SS "Installing" .sp .if n \{\ .RS 4 .\} .nf gem install detest .fi .if n \{\ .RE .\} .SS "Upgrading" .sp .if n \{\ .RS 4 .\} .nf gem update detest .fi .if n \{\ .RE .\} .SS "Removing" .sp .if n \{\ .RS 4 .\} .nf gem uninstall detest .fi .if n \{\ .RE .\} .SH "USAGE" .sp Begin by loading the Detest library into your program: .sp .if n \{\ .RS 4 .\} .nf require \'rubygems\' # might not be necessary; see HACKING require \'detest\' .fi .if n \{\ .RE .\} .sp You can now call methods on the Detest module directly: .sp .if n \{\ .RS 4 .\} .nf Detest\&.D \'hello\' do # D() is a class method puts \'world\' end .fi .if n \{\ .RE .\} .sp or mix\-in the module and call its methods implicitly: .sp .if n \{\ .RS 4 .\} .nf include Detest # mix\-in the Detest module D \'hello\' do # D() is an instance method puts \'world\' end .fi .if n \{\ .RE .\} .sp You can configure the test execution process using: .sp .if n \{\ .RS 4 .\} .nf Detest\&.debug = true # or false .fi .if n \{\ .RE .\} .sp You can execute all tests defined thus far, in depth\-first search (DFS) order, using: .sp .if n \{\ .RS 4 .\} .nf Detest\&.start .fi .if n \{\ .RE .\} .sp You can stop the execution at any time using: .sp .if n \{\ .RS 4 .\} .nf Detest\&.stop .fi .if n \{\ .RE .\} .sp You can view the results of execution using: .sp .if n \{\ .RS 4 .\} .nf puts Detest\&.trace\&.to_yaml puts Detest\&.stats\&.to_yaml .fi .if n \{\ .RE .\} .sp You can clear the results of execution using: .sp .if n \{\ .RS 4 .\} .nf Detest\&.reset .fi .if n \{\ .RE .\} .sp You can mix\-in the Detest module into your program and execute all tests defined by your program before it terminates by simply adding the following line at the top of your program: .sp .if n \{\ .RS 4 .\} .nf require \'detest/auto\' .fi .if n \{\ .RE .\} .sp See the API documentation for more information and examples\&. .SH "TESTS" .SS "Defining tests" .sp The D() method creates a new \fBtest\fR, which is analagous to the \fBdescribe\fR keyword in [RSpec] and also to the concept of a "test case" in [xUnit]\&. .sp .if n \{\ .RS 4 .\} .nf D "outer test" do # assertions and logic here D "inner test" do # more assertions and logic here end end .fi .if n \{\ .RE .\} .sp A test may contain nested tests, as illustrated above\&. .SS "Insulating tests" .sp The D!() method defines a new test that is explicitly insulated from the tests that contain it and also from the top\-level Ruby environment\&. Root\-level calls to the D() method are insulated by default\&. .sp Inside an insulated test, you are free to mix\-in (using the \fBextend\fR keyword, not the \fBinclude\fR keyword) any modules your test logic needs\&. You can also define your own constants, methods, classes, and modules here\&. .PP \fBExample\ \&1.\ \&Insulated and uninsulated tests\fR .sp When the following test is run: .sp .if n \{\ .RS 4 .\} .nf require \'detest/auto\' D "a root\-level test" do @outside = 1 T { defined? @outside } T { @outside == 1 } D "an inner, non\-insulated test" do T { defined? @outside } T { @outside == 1 } end D! "an inner, insulated test" do F { defined? @outside } F { @outside == 1 } @inside = 2 T { defined? @inside } T { @inside == 2 } end F { defined? @inside } F { @inside == 2 } end .fi .if n \{\ .RE .\} .sp Detest will output the following: .sp .if n \{\ .RS 4 .\} .nf \-\-\- \- a root\-level test: \- an inner, non\-insulated test: \- an inner, insulated test: \-\-\- pass: 10 time: 0\&.009435692 .fi .if n \{\ .RE .\} .SS "Sharing tests" .TS tab(:); lt lt lt lt lt lt. T{ .sp S() T}:T{ .sp Mechanism for sharing code\&. It can be used in two ways: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} When called with a block, it shares the given block (under a given identifier) for injection into other tests\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} When called without a block, it injects a previously shared block (under a given identifier) into the environment where it is called\&. .RE T} T{ .sp S!() T}:T{ .sp Combination of the two uses of the S() method: it lets you simultaneously share a block of code while injecting it into the environment where that method is called\&. T} T{ .sp S?() T}:T{ .sp Checks whether any code has been shared under a given identifier\&. T} .TE .sp 1 .PP \fBExample\ \&2.\ \&Sharing code between tests\fR .sp When the following test is run: .sp .if n \{\ .RS 4 .\} .nf require \'detest/auto\' S :knowledge do I \'Knowledge is power!\' end D \'Healer\' do S :knowledge end D \'Warrior\' do S! :strength do I \'Strength is power!\' end end D \'Wizard\' do S :knowledge S :strength end D \'King\' do T { S? :knowledge } T { S? :strength } F { S? :power } I \'Power is power!\' end .fi .if n \{\ .RE .\} .sp Detest will output the following: .sp .if n \{\ .RS 4 .\} .nf \-\-\- \- Healer: \- Knowledge is power! \- Warrior: \- Strength is power! \- Wizard: \- Knowledge is power! \- Strength is power! \- King: \- Power is power! \-\-\- pass: 3 time: 0\&.007379665 .fi .if n \{\ .RE .\} .SS "Logging information" .TS tab(:); lt lt lt lt. T{ .sp I() T}:T{ .sp Mechanism for inserting arbitrary Ruby objects into the test execution report\&. You can think of this method as being a way \fIto inform\fR someone\&. T} T{ .sp I!() T}:T{ .sp Starts the interactive debugger at the location where it is called\&. T} .TE .sp 1 .PP \fBExample\ \&3.\ \&Logging information in the execution report\fR .sp When the following test is run: .sp .if n \{\ .RS 4 .\} .nf require \'detest/auto\' D \'Wizard\' do I \'Preparing spell to defeat mortal foes\&.\&.\&.\' end D \'Magician\' do I \'Preparing rabbits to pull from hat\&.\&.\&.\', rand(15) end D \'Calculator\' do I Math::PI, [1, 2, 3, [\'a\', \'b\', \'c\']], {:foo => \'bar!\'} end .fi .if n \{\ .RE .\} .sp Detest will output the following: .sp .if n \{\ .RS 4 .\} .nf \-\-\- \- Wizard: \- Preparing spell to defeat mortal foes\&.\&.\&. \- Magician: \- Preparing rabbits to pull from hat\&.\&.\&. \- 6 \- Calculator: \- 3\&.141592653589793 \- \- 1 \- 2 \- 3 \- \- a \- b \- c \- foo: bar! \-\-\- time: 0\&.00284595 .fi .if n \{\ .RE .\} .SS "Execution hooks" .sp A \fBhook\fR is a scheduled point of entry into the test execution process\&. The following \fBhook methods\fR allow you to register a block of code to execute when a hook occurs: .TS tab(:); lt lt lt lt lt lt lt lt. T{ .sp D\&.<() T}:T{ .sp Calls the given block \fIbefore each\fR child test\&. T} T{ .sp D\&.>() T}:T{ .sp Calls the given block \fIafter each\fR child test\&. T} T{ .sp D\&.<<() T}:T{ .sp Calls the given block \fIbefore all\fR child tests\&. T} T{ .sp D\&.>>() T}:T{ .sp Calls the given block \fIafter all\fR child tests\&. T} .TE .sp 1 .sp A hook method can be called multiple times\&. Each additional call schedules more logic to be executed during the hook: .sp .if n \{\ .RS 4 .\} .nf D \&.< { puts "do something" } D \&.< { puts "do something more!" } .fi .if n \{\ .RE .\} .PP \fBExample\ \&4.\ \&Using hooks to perform before and after actions\fR .sp When the following test is run: .sp .if n \{\ .RS 4 .\} .nf require \'detest/auto\' D "outer test" do D \&.< { I "(outer hook) before each" } D \&.> { I "(outer hook) after each" } D \&.<< { I "(outer hook) before all" } D \&.>> { I "(outer hook) after all" } D "inner test 1" do D \&.< { I "(inner hook) before each" } D \&.> { I "(inner hook) after each" } D \&.<< { I "(inner hook) before all" } D \&.>> { I "(inner hook) after all" } D "inner test 1\&.1" do I "hello world" end end D "inner test 2" do I "goodbye world" end D \&.< { I "(outer hook) before each, again" } D \&.> { I "(outer hook) after each, again" } end .fi .if n \{\ .RE .\} .sp Detest will output the following: .sp .if n \{\ .RS 4 .\} .nf \-\-\- \- outer test: \- (outer hook) before all \- (outer hook) before each \- (outer hook) before each, again \- inner test 1: \- (inner hook) before all \- (inner hook) before each \- inner test 1\&.1: \- hello world \- (inner hook) after each \- (inner hook) after all \- (outer hook) after each \- (outer hook) after each, again \- (outer hook) before each \- (outer hook) before each, again \- inner test 2: \- goodbye world \- (outer hook) after each \- (outer hook) after each, again \- (outer hook) after all \-\-\- time: 0\&.007706195 .fi .if n \{\ .RE .\} .SH "ASSERTIONS" .SS "Writing assertions" .sp The following methods accept a block parameter and assert something about the result of executing that block\&. They also accept an optional message, which is shown in their failure reports if they fail\&. .TS tab(:); lt lt lt lt lt lt lt lt lt lt. T{ .sp T() T}:T{ .sp assert true (not nil and not false) T} T{ .sp F() T}:T{ .sp assert not true (nil or false) T} T{ .sp N() T}:T{ .sp assert that the value is nil T} T{ .sp E() T}:T{ .sp assert that an execption is raised T} T{ .sp C() T}:T{ .sp assert that a symbol is thrown T} .TE .sp 1 .sp For the T() and F() methods, you may alternatively pass the condition to be asserted as the first argument (instead of passing it as a block)\&. This might result in a more pleasing syntax, depending on your taste: .sp .if n \{\ .RS 4 .\} .nf D "Lottery" do winning_ticket = rand() D "My chances of winning" do my_ticket = rand() # # Option 1: passing the condition as a block: # F("I won?! Dream on\&.") { my_ticket == winning_ticket } # # Option 2: passing the condition as an argument: # F my_ticket == winning_ticket, "I won?! Dream on\&." end end .fi .if n \{\ .RE .\} .SS "Negating assertions" .sp The following methods are the \fIopposite\fR of normal assertions\&. .TS tab(:); lt lt lt lt lt lt lt lt lt lt. T{ .sp T!() T}:T{ .sp same as F() T} T{ .sp F!() T}:T{ .sp same as T() T} T{ .sp N!() T}:T{ .sp assert that value is not nil T} T{ .sp E!() T}:T{ .sp assert that an exception is \fInot\fR raised T} T{ .sp C!() T}:T{ .sp assert that a symbol is \fInot\fR thrown T} .TE .sp 1 .SS "Sampling assertions" .sp The following methods let you \fIcheck the outcome\fR of an assertion without recording a success or failure in the test execution report\&. .TS tab(:); lt lt lt lt lt lt lt lt lt lt. T{ .sp T?() T}:T{ .sp returns true if T() passes; false otherwise T} T{ .sp F?() T}:T{ .sp returns true if F() passes; false otherwise T} T{ .sp N?() T}:T{ .sp returns true if N() passes; false otherwise T} T{ .sp E?() T}:T{ .sp returns true if E() passes; false otherwise T} T{ .sp C?() T}:T{ .sp returns true if C() passes; false otherwise T} .TE .sp 1 .SS "Assertion failure reports" .sp Assertions failures are reported in the following manner: .sp .if n \{\ .RS 4 .\} .nf \- fail: block must yield true (!nil && !false) call: \- test/simple\&.rb:17 \- test/simple\&.rb:3 code: |\- [12\&.\&.22] in test/simple\&.rb 12 13 D "with more nested tests" do 14 x = 5 15 16 T { x > 2 } # passes => 17 F { x > 2 } # fails 18 E { x\&.hello } # passes 19 end 20 end 21 22 # equivalent of before(:each) or setup() bind: test/simple\&.rb:17 vars: x: (Fixnum) 5 y: (Fixnum) 83 .fi .if n \{\ .RE .\} .sp Failure reports are composed of the following sections: .TS tab(:); lt lt lt lt lt lt lt lt lt lt. T{ .sp :fail T}:T{ .sp Description of the assertion failure\&. T} T{ .sp :call T}:T{ .sp Stack trace leading to the point of failure\&. T} T{ .sp :code T}:T{ .sp Source code surrounding the point of failure\&. T} T{ .sp :bind T}:T{ .sp Source location of values in :vars section\&. T} T{ .sp :vars T}:T{ .sp Local variables visible at the point of failure\&. T} .TE .sp 1 .sp After the failure is reported, you will be placed into a debugger to investigate the failure if the Detest\&.debug option is enabled\&. .sp Assertion failure reports can be accessed at any time within the test execution trace provided by the Detest\&.trace() method\&. .SH "EMULATION" .sp Detest can emulate several popular testing libraries: .TS tab(:); lt lt lt lt lt lt lt lt. T{ .sp detest/spec T}:T{ .sp [RSpec] emulation layer T} T{ .sp detest/unit T}:T{ .sp [Test::Unit] emulation layer T} T{ .sp detest/mini T}:T{ .sp [Minitest] emulation layer T} T{ .sp detest/long T}:T{ .sp Readability emulation layer T} .TE .sp 1 .sp Simply require one of these emulation layers into your test suite and you can write your tests using the familiar syntax of the testing library it emulates\&. .SS "detest/spec" .sp This library emulates [RSpec] by adding the following methods to the Detest module\&. .TS tab(:); lt lt lt lt lt lt lt lt lt lt. T{ .sp after(\fIwhat\fR, &\fIblock\fR) T}:T{ .sp lib/detest/spec\&.rb:21 T} T{ .sp before(\fIwhat\fR, &\fIblock\fR) T}:T{ .sp lib/detest/spec\&.rb:10 T} T{ .sp context(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp describe(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp it(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} .TE .sp 1 .SS "detest/unit" .sp This library emulates [Test::Unit] by adding the following methods to the Detest module\&. .TS tab(:); lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt. T{ .sp assert(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp assert_empty(\fIcollection\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:26 T} T{ .sp assert_equal(\fIexpected\fR, \fIactual\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:31 T} T{ .sp assert_in_delta(\fIexpected\fR, \fIactual\fR, \fIdelta\fR=nil, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:36 T} T{ .sp assert_in_epsilon(\fIexpected\fR, \fIactual\fR, \fIdelta\fR=nil, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:36 T} T{ .sp assert_include(\fIitem\fR, \fIcollection\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:47 T} T{ .sp assert_instance_of(\fIklass\fR, \fIobject\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:52 T} T{ .sp assert_kind_of(\fIklass\fR, \fIobject\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:57 T} T{ .sp assert_match(\fIpattern\fR, \fIstring\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:67 T} T{ .sp assert_nil(\fIobject\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:62 T} T{ .sp assert_not(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp assert_not_empty(\fIcollection\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:26 T} T{ .sp assert_not_equal(\fIexpected\fR, \fIactual\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:31 T} T{ .sp assert_not_in_delta(\fIexpected\fR, \fIactual\fR, \fIdelta\fR=nil, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:36 T} T{ .sp assert_not_in_epsilon(\fIexpected\fR, \fIactual\fR, \fIdelta\fR=nil, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:36 T} T{ .sp assert_not_include(\fIitem\fR, \fIcollection\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:47 T} T{ .sp assert_not_instance_of(\fIklass\fR, \fIobject\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:52 T} T{ .sp assert_not_kind_of(\fIklass\fR, \fIobject\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:57 T} T{ .sp assert_not_match(\fIpattern\fR, \fIstring\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:67 T} T{ .sp assert_not_nil(\fIobject\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:62 T} T{ .sp assert_not_operator(\fIobject\fR, \fIoperator\fR, \fIoperand\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:77 T} T{ .sp assert_not_raise(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest/unit\&.rb:82 T} T{ .sp assert_not_respond_to(\fIobject\fR, \fIquery\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:86 T} T{ .sp assert_not_same(\fIexpected\fR, \fIactual\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:72 T} T{ .sp assert_not_send(\fIobject\fR, \fIquery\fR, *\fIargs\fR) T}:T{ .sp lib/detest/unit\&.rb:95 T} T{ .sp assert_not_throw(\fIsymbol\fR, \fImessage\fR=nil, &\fIblock\fR) T}:T{ .sp lib/detest/unit\&.rb:91 T} T{ .sp assert_operator(\fIobject\fR, \fIoperator\fR, \fIoperand\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:77 T} T{ .sp assert_raise(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest/unit\&.rb:82 T} T{ .sp assert_respond_to(\fIobject\fR, \fIquery\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:86 T} T{ .sp assert_same(\fIexpected\fR, \fIactual\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:72 T} T{ .sp assert_send(\fIobject\fR, \fIquery\fR, *\fIargs\fR) T}:T{ .sp lib/detest/unit\&.rb:95 T} T{ .sp assert_throw(\fIsymbol\fR, \fImessage\fR=nil, &\fIblock\fR) T}:T{ .sp lib/detest/unit\&.rb:91 T} T{ .sp setup(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp setup!(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp teardown(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp teardown!(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp test(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} .TE .sp 1 .SS "detest/mini" .sp This library emulates [Minitest] by adding the following methods to the Detest module\&. .TS tab(:); lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt. T{ .sp refute(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp refute_empty(\fIcollection\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:26 T} T{ .sp refute_equal(\fIexpected\fR, \fIactual\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:31 T} T{ .sp refute_in_delta(\fIexpected\fR, \fIactual\fR, \fIdelta\fR=nil, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:36 T} T{ .sp refute_in_epsilon(\fIexpected\fR, \fIactual\fR, \fIdelta\fR=nil, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:36 T} T{ .sp refute_include(\fIitem\fR, \fIcollection\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:47 T} T{ .sp refute_instance_of(\fIklass\fR, \fIobject\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:52 T} T{ .sp refute_kind_of(\fIklass\fR, \fIobject\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:57 T} T{ .sp refute_match(\fIpattern\fR, \fIstring\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:67 T} T{ .sp refute_nil(\fIobject\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:62 T} T{ .sp refute_operator(\fIobject\fR, \fIoperator\fR, \fIoperand\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:77 T} T{ .sp refute_raise(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest/unit\&.rb:82 T} T{ .sp refute_respond_to(\fIobject\fR, \fIquery\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:86 T} T{ .sp refute_same(\fIexpected\fR, \fIactual\fR, \fImessage\fR=nil) T}:T{ .sp lib/detest/unit\&.rb:72 T} T{ .sp refute_send(\fIobject\fR, \fIquery\fR, *\fIargs\fR) T}:T{ .sp lib/detest/unit\&.rb:95 T} T{ .sp refute_throw(\fIsymbol\fR, \fImessage\fR=nil, &\fIblock\fR) T}:T{ .sp lib/detest/unit\&.rb:91 T} .TE .sp 1 .SS "detest/long" .sp This library emulates Readability by adding the following methods to the Detest module\&. .TS tab(:); lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt. T{ .sp Catch(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Catch!(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Catch?(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Describe(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Describe!(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Error(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Error!(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Error?(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp False(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp False!(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp False?(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Inform(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Inform!(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Nil(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Nil!(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Nil?(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Share(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Share!(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp Share?(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp True(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp True!(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} T{ .sp True?(*\fIargs\fR, &\fIblock\fR) T}:T{ .sp lib/detest\&.rb:1168 T} .TE .sp 1 .SH "HACKING" .SS "Prerequisites" .sp Install Ruby libraries necessary for development: .sp .if n \{\ .RS 4 .\} .nf gem install detest \-\-development .fi .if n \{\ .RE .\} .SS "Infrastructure" .sp [Inochi] serves as the project infrastructure for Detest\&. It handles tasks such as building this help manual and API documentation, and packaging, announcing, and publishing new releases\&. See its help manual and list of tasks to get started: .sp .if n \{\ .RS 4 .\} .nf inochi \-\-help # display help manual inochi \-\-tasks # list available tasks .fi .if n \{\ .RE .\} .SS "$LOAD_PATH setup" .sp Ensure that the lib/ directory is listed in Ruby\(cqs $LOAD_PATH before you use any libraries therein or run any executables in the bin/ directory\&. .sp This can be achieved by passing an option to Ruby: .sp .if n \{\ .RS 4 .\} .nf ruby \-Ilib bin/detest irb \-Ilib \-r detest .fi .if n \{\ .RE .\} .sp Or by setting the $RUBYLIB environment variable: .sp .if n \{\ .RS 4 .\} .nf export RUBYLIB=lib # bash, ksh, zsh setenv RUBYLIB lib # csh set \-x RUBYLIB lib # fish ruby bin/detest irb \-r detest .fi .if n \{\ .RE .\} .sp Or by running Ruby through the ruby\-wrapper tool\&. .SS "RubyGems setup" .sp If you use Ruby 1\&.8 or older, then ensure that RubyGems is activated before you use any libraries in the lib/ directory or run any executables in the bin/ directory\&. .sp This can be achieved by passing an option to Ruby: .sp .if n \{\ .RS 4 .\} .nf ruby \-rubygems bin/detest irb \-rubygems \-r detest .fi .if n \{\ .RE .\} .sp Or by setting the $RUBYOPT environment variable: .sp .if n \{\ .RS 4 .\} .nf export RUBYOPT=\-rubygems # bash, ksh, zsh setenv RUBYOPT \-rubygems # csh set \-x RUBYOPT \-rubygems # fish .fi .if n \{\ .RE .\} .SS "Running tests" .sp Simply execute the included test runner, which sets up Ruby\(cqs $LOAD_PATH for testing, loads the test/helper\&.rb file, and then evaluates all test/**/*_test\&.rb files: .sp .if n \{\ .RS 4 .\} .nf ruby test/runner .fi .if n \{\ .RE .\} .sp Its exit status will indicate whether all tests have passed\&. It may also print additional pass/fail information depending on the testing library used in the test/helper\&.rb file\&. .SS "Contributing" .sp Fork this project on GitHub and send a pull request\&. .SH "HISTORY" .SS "Version 3\&.1\&.1 (2010\-08\-08)" .sp This release adds forgotten nil assertions and updates the help manual\&. .PP \fBBug fixes\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Forgot to add nil assertion methods in the detest/long library\&. .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Upgrade to Inochi 5\&.0\&.0; the help manual is now written in AsciiDoc\&. .RE .SS "Version 3\&.1\&.0 (2010\-07\-25)" .sp This release adds N() methods for nil value assertions and renames the project from "DIFECTS" to "Detest" to avoid forming a habit of intentional misspellings\&. .PP \fBNew features\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add N(), N!(), and N?() methods for asserting that a value is nil\&. This idea comes from Gavin Sinclair\(cqs [Attest] assertion testing library\&. .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Rename project from "DIFECTS" to "Detest"\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Upgrade project to Inochi 4\&.0\&.0 infrastructure\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Minor code refactoring and manual revisions\&. .RE .SS "Version 3\&.0\&.1 (2010\-07\-25)" .sp This release fixes a bug in Ruby 1\&.8, refactors the code, and better documents test hooks in the manual\&. .PP \fBBug fixes\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Ruby 1\&.8 does not pass value to Hash#delete_if()\&. All failure details were being omitted, instead of just the unavailable ones, as a result\&. .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Refactor variable values hash calculation and pretty printing logic\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Put FailureDetails pretty\-printing modules into their own namespace\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Raise error if closest insulated test cannot be not found\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Describe all test hooks and add example to manual, plus small revisions\&. .RE .SS "Version 3\&.0\&.0 (2010\-07\-24)" .sp This release renames the project from "Dfect" to "DIFECTS", reduces cruft, improves the presentation and debuggability of assertion failures, and revises the manual\&. .PP \fBThank you\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Gavin Sinclair inspired me to work on this project again! .RE .PP \fBIncompatible changes\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Rename project from "Dfect" to "DIFECTS", which stands for: .sp \fBD\fRescribe, \fBI\fRnform, \fBF\fRalse, \fBE\fRrror, \fBC\fRatch, \fBT\fRrue, \fBS\fRhare .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Remove [ruby-debug] integration because it is only helpful if you run a program inside it from the very start! That is, you cannot start ruby\-debug in the middle of a program and expect it to know about the call stack that lead up to that point in the program\&. Instead, we now use IRB to inspect program state at the point of failure only\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Remove \-\-quiet option because user can pipe to /dev/null instead\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Rename run() to start() to better complement stop()\&. The run() method no longer clears test results; use reset() for that\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Rename L() to I() as in "inform" the user\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Replace options() with debug()\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Replace report() with trace() and stats()\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Rename the difects/full library to difects/long\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Do not report instance variables in assertion failures\&. .RE .PP \fBNew features\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Improve debuggability by tracking the bindings of all lines of code executed leading up to the point of failure using Ruby\(cqs awesome set_trace_func facility\&. .sp This allows block\-less assertions to be debugged with the same level of accuracy as normal block\-given assertions: .sp .if n \{\ .RS 4 .\} .nf x = 1 y = 3 T { x == y } # a block\-given assertion T x == y # a block\-less assertion .fi .if n \{\ .RE .\} .sp In both cases, you will be able to inspect the local variables x and y! .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add I!() method to start the interactive debugger anywhere in your tests\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add reset() to manually clear previous test results\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Alias test() to D() in [Test::Unit] emulation layer\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Fallback to pp() if to_yaml() fails while reporting failures\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Use [OrderedHash] library in Ruby versions older than 1\&.9 for consistent presentation of information in assertion failures\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Show full failure details before starting debugger instead of omitting the backtrace and local variables listing\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Use PP to pretty\-print variable values in failure details\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Omit unavailable information from failure details\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Put backtrace above code listing and variables in failure details\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Prevent empty array leaf nodes in execution trace\&. .RE .PP \fBBug fixes\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Make DIFECTS module\(cqs instance methods available as class methods\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Always display fail trace before entering debugger\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Always clear test execution internals after start()\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Prevent IRB re\-initialization errors when starting debugger\&. .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Clarify how to mix\-in modules inside insulated tests in the manual\&. Thanks to Gavin Sinclair for reporting this issue\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Document methods (with hyperlinks to the location in the source code where they are defined) provided by emulation layers in manual\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Talk about passing condition as first argument to T and F assertions and provide a code example in the manual\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Clean up the code and revise the manual\&. Yay! .RE .SS "Version 2\&.2\&.0 (2010\-04\-28)" .sp This release adds a UNIX manual page and a sub\-library for full method names\&. .PP \fBNew features\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add dfect/full sub\-library that provides full name aliases to Dfect\(cqs abbreviated vocabulary: .sp \fBD\fRescribe, \fBT\fRrue, \fBF\fRalse, \fBE\fRrror, \fBC\fRatch, \fBS\fRhare, \fBL\fRog .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Run dfect \-\-help to see the UNIX manual page! .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Upgrade to Inochi 3\&.0\&.0 and revise the help manual\&. .RE .SS "Version 2\&.1\&.0 (2010\-03\-31)" .sp This release adds a command\-line test runner and performs some minor housekeeping\&. .PP \fBNew features\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add bin/dfect executable as command\-line interface to this library\&. .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Do not require \'rubygems\' before loading the "ruby\-debug" library\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Upgrade to Inochi 2\&.0\&.0\-rc2 for managing this project\&. .RE .SS "Version 2\&.0\&.0 (2010\-03\-21)" .sp This release adds the ability to insulate tests from each other, share code between them, makes the order of parameters consistent in the API, improves user interactivity, fixes some bugs, and revises the user manual\&. .PP \fBIncompatible changes\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Root\-level calls to the Dfect::D() method are automatically insulated now\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The Dfect::E() methods now expects its optional message parameter to be the \fIlast parameter\fR in the parameter list\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The Dfect::C() methods now expect their first parameter to be a symbol instead of the optional message to be shown in case of assertion failure\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The Dfect::R() has been renamed to Dfect::L(), which is a mnemonic for "Logging"\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Shorten names of hash keys in the execution trace for brevity and rename :raise key in report statistics to :error\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Only the most helpful subset of the failure details is shown before placing the user into a debugger because they can query the omitted information (on demand) inside the debugger\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The execution trace is only shown if all tests passed in Dfect::run()\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The :debug option is now set to Ruby\(cqs $DEBUG global by default\&. .RE .PP \fBNew features\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Print failures as they occur instead of waiting until the end\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Allow passing condition as argument to true/false assertions instead of requiring the condition to be passed as a code block, and also fall back to the binding of inner\-most enclosing test or hook when debugging or constructing a failure report for an assertion that was not given a block\&. .sp This allows you to reduce "line noise" in your tests: .sp .if n \{\ .RS 4 .\} .nf D "Lottery" do winning_ticket = rand() D "My chances of winning" do my_ticket = rand() F my_ticket == winning_ticket, "I won?! Dream on\&." end end .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add Dfect::S() methods for sharing code between tests\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add Dfect::D!() method to explicitly insulate a test from other tests, the top\-level Ruby environment, and the code being tested\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add Dfect::info() method which returns the details of the failure that is currently being debugged by the user\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add instance variables to the :vars section of a failure report\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add setup!() and teardown!() methods for before\-all and after\-all hooks in the dfect/unit emulation library\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add test execution time to statistics hash (under the :time key)\&. .RE .PP \fBBug fixes\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Do not print any output when :quiet option is active\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Allow passing multiple strings/objects to Dfect::D() like in RSpec\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Make before and after hook methods mixin\-able like assertions\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Do not assume that Module#to_s is the same as Module#name\&. .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Upgrade to Inochi 2\&.0\&.0\-rc1 for managing this project\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Make emulation libraries modify Dfect module instead of Kernel\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Do not pollute the user\(cqs output with our Class#to_yaml workaround\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Remove "Motivation" section from user manual\&. It was too fanatic! .RE .SS "Version 1\&.1\&.0 (2009\-10\-27)" .sp This release adds a new method for emitting status messages and does some internal housekeeping\&. .PP \fBThank you\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Iñaki Baz Castillo used Dfect and suggested new features\&. .RE .PP \fBNew features\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add Dfect::S() method for adding status messages to the execution report\&. This feature was requested by Iñaki Baz Castillo\&. .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Remove unused require of delegate standard library in dfect/spec RSpec emulation layer\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Mention emulation layers for popular testing libraries\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Mention that assertions take an optional message parameter\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Replace sample unit test with Dfect test suite\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Upgrade user manual to ERBook 9\&.0\&.0\&. .RE .SS "Version 1\&.0\&.1 (2009\-10\-07)" .sp This release fixes a bug in the [Test::Unit] emulation library and revises the user manual\&. .PP \fBBug fixes\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The parameters for the assert_equal() method in the dfect/unit library were in the wrong order\&. .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Revise user manual to better fit jQuery UI tabs\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Justify the use of eval() in emulation libraries\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Use simpler Copyright reminder at the top of every file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Make SLOC count in user manual reflect the \fIcore\fR library only\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Mark code spans with {:lang=ruby} instead of HTML tags\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Open source is for fun, so be nice and speak of "related works" instead of "competitors"\&. .RE .SS "Version 1\&.0\&.0 (2009\-05\-03)" .sp This release improves default choices, adds emulation layers to mimic other testing libraries, and fixes some bugs\&. .PP \fBIncompatible changes\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The :debug option is now enabled by default and is no longer linked to the value of $DEBUG\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Dfect\&.run() now appends to previous results by default\&. This behavior can be disabled by passing false to the method\&. .RE .PP \fBNew features\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add emulation layers to mimic other testing libraries: .TS tab(:); lt lt lt lt lt lt. T{ dfect/unit T}:T{ [Test::Unit] emulation layer T} T{ dfect/mini T}:T{ [Minitest] emulation layer T} T{ dfect/spec T}:T{ [RSpec] emulation layer T} .TE .sp 1 .RE .PP \fBBug fixes\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Do not blindly replace Class#to_yaml; it might be fixed someday\&. .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add "Motivation" section in user manual to promote interactive debugging\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add brief History of this project\(cqs inception\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Remove redundant assertions for F!() and T!() methods in test suite\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add copyright notice at the top of every file\&. .RE .SS "Version 0\&.1\&.0 (2009\-04\-28)" .sp This release adds new variations to assertion methods, fixes several bugs, and improves test coverage\&. .PP \fBThank you\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} François Beausoleil contributed patches for both code \fIand\fR tests! :\-) .RE .PP \fBNew features\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Added negation (m!) and sampling (m?) variations to normal assertion methods\&. These new methods implement assertion functionality missing so far (previously we could not assert that a given exception was NOT thrown) and thereby allow us to fully test Dfect using itself\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Added documentation on how to insulate tests from the global Ruby namespace\&. .RE .PP \fBBug fixes\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The E() method did not consider the case where a block does not raise anything as a failure\&. Thanks to François Beausoleil for reporting this\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When creating a report about an assertion failure, an exception would be thrown if any local variables pointed to an empty array\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The Dfect::<() method broke the inheritance\-checking behavior of the < class method\&. I added a bypass to the originial behavior so that RCov::XX can properly generate a report about code that uses Dfect\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Added workaround for YAML error that occurs when serializing a class object: .sp .if n \{\ .RS 4 .\} .nf TypeError: can\'t dump anonymous class Class .fi .if n \{\ .RE .\} .RE .PP \fBHousekeeping\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Filled the big holes in test coverage\&. Everything except the runtime debugging logic is now covered by the unit tests\&. .RE .SS "Version 0\&.0\&.0 (2009\-04\-13)" .sp For the longest time, I took [Test::Unit] and [RSpec] for granted\&. They were the epitomy of modern Ruby practice; the insurmountable status quo; immortalized in books, conferences, and blogs alike\&. .sp Why would \fIanyone\fR think of using anything remotely different, let alone be foolish enough to write an alternative testing library when these are clearly "good enough"? .sp Recent experiments in assertion testing libraries smashed my world view: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} [assert2] .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} [Testy] .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} [Verify] .RE .sp The status quo was certainly \fInot\fR "good enough", as I had so blindly believed all these years\&. In fact, they were \fIverbose\fR behemoths that chose to encode endless permutations of conjecture into methods\&. .sp Empowered by this revelation and inspired by Sean O\(cqHalpin\(cqs musing on alternative names for assertion methods, I rose to challenge the status quo\&. .sp And so I present to you the first public release of "Dfect"\&. .SH "AUTHORS" .sp Suraj N\&. Kurapati .SS "Credits" .sp François Beausoleil, Gavin Sinclair, Iñaki Baz Castillo, Sean O\(cqHalpin .SS "License" .sp (the ISC license) .sp Copyright 2009 Suraj N\&. Kurapati .sp Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies\&. .sp THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\&. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE\&. .SH "SEE ALSO" .sp [Attest], [assert2], [Testy], [Verify] .SS "References" .TS tab(:); lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt. T{ .sp assert2 T}:T{ .sp http://assert2\&.rubyforge\&.org T} T{ .sp Attest T}:T{ .sp http://gsinclair\&.github\&.com/attest\&.html T} T{ .sp Inochi T}:T{ .sp http://snk\&.tuxfamily\&.org/lib/inochi/ T} T{ .sp Minitest T}:T{ .sp http://blog\&.zenspider\&.com/minitest/ T} T{ .sp OrderedHash T}:T{ .sp http://rubygems\&.org/gems/orderedhash T} T{ .sp RSpec T}:T{ .sp http://rspec\&.info T} T{ .sp ruby\-debug T}:T{ .sp http://github\&.com/mark\-moseley/ruby\-debug T} T{ .sp RubyGems T}:T{ .sp http://rubygems\&.org T} T{ .sp Ruby T}:T{ .sp http://ruby\-lang\&.org T} T{ .sp Test::Unit T}:T{ .sp http://ruby\-doc\&.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit\&.html T} T{ .sp Testy T}:T{ .sp http://github\&.com/ahoward/testy/tree/master T} T{ .sp Verify T}:T{ .sp http://www\&.ruby\-forum\&.com/topic/183354 T} T{ .sp xUnit T}:T{ .sp http://en\&.wikipedia\&.org/wiki/XUnit T} .TE .sp 1