librelist archives

« back to archive

[Programming] On automated tests

[Programming] On automated tests

From:
Pradeep Gowda
Date:
2010-07-30 @ 14:15
Yesterday, I discovered "Ruby Best Practices" book on Hacker News.

It is published by O'Reilly and is available for download  as a PDF file
from the book's website [1].

The very first chapter talks about Test Driven Development.

An extract about why writing automated tests need not feel like a additional
burden to programmers:

> However, the important thing to take home from this is that automated
testing is really
no different than what we did before we discovered it. If you’ve ever tried
to narrow
down a bug with a print statement based on a conditional, you’ve already
written a
primitive form of automated testing:

    if foo != "blah"
        puts "I expected 'blah' but foo contains #{foo}"
    end

> If you’ve ever written an example to verify that a bug exists in an
earlier version of code,
but not in a later one, you’ve written something not at all far from the
sorts of things
you’ll write through TDD. The only difference is that one-off examples do
not ade-
quately account for the problems that can arise during integration with
other modules.
This problem can become huge, and is one that unit testing frameworks handle
quite
well.

[1]: http://rubybestpractices.com/