Dfect is an assertion testing library for Ruby that emphasizes a simple assertion vocabulary, instant debuggability of failures, and flexibility in composing tests.
- What’s new? — history of project releases.
- Source code — obtain via Git or browse online.
- API reference — documentation for source code.
- Project home — the Dfect project home page.
To get help or provide feedback, simply contact the author(s).
1.1 Features
Dfect is exciting because:
- It has only 5 methods to remember: D F E C T.
- It lets you debug assertion failures interactively.
- It keeps a detailed report of assertion failures.
- It lets you nest tests and execution hooks.
- Its core consists of a mere 313 lines of code.
1.2 Motivation
The basic premise of Dfect is that, when a failure occurs, I want to be put inside an interactive debugger where I have the freedom to properly scrutinize the state of my program and determine the root cause of the failure.
Other testing libraries do not fulfill this need. Instead, they simply report each failed assertion along with a stack trace (if I am lucky) and abruptly terminate my program.
This deliberate separation of fault (my program being in an erroneous state) and cause (the source code of my program which caused the fault) reduces me to a primitive and laborious investigative technique known as ”printf debugging”.
If you are not the least bit unsettled by those two words, then recall your first encounter with IRB, the interactive Ruby shell: remember how you would enter code expressions and IRB would instantly evaluate them and show you the result?
What an immense productivity boost! A stark contrast to the endless toil of wrapping every such experiment in standard boilerplate (public static void
…), saving the result to a correctly named file, invoking the C/C++/Java compiler, and finally executing the binary—only to be greeted by a segfault. ;-)
I exaggerate, for the sake of entertainment, of course. But my point is that the Ruby testing libraries of today have (thus far) limited our productivity by orphaning us from the nurturing environment of IRB and shooing us off to a barren desert of antiquated techniques. How cruel!
And that, I say, is why Dfect is essential to Ruby developers today. It reunites us with our playful, interactive, real-time IRB roots and, with unwavering tenacity, enables us to investigate failures productively!
1.3 Etymology
Dfect is named after the D F E C T methods it provides.
The name is also play on the word “defect”, whereby the intentional misspelling of “defect” as “dfect” is a defect in itself! ;-)
This wordplay is similar to Mnesia’s play on the word “amnesia”, whereby the intentional omission of the letter “A” indicates forgetfulness—the key characteristic of having amnesia. Clever!
1.4 License
(the ISC license)
Copyright 2009 Suraj N. Kurapati sunaku@gmail.com
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.
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.