This post originated from an RSS feed registered with Python Buzz
by Jarno Virtanen.
Original Post: On test-driven development and white-box methods again
Feed Title: Python owns us
Feed URL: http://sedoparking.com/search/registrar.php?domain=®istrar=sedopark
Feed Description: A weblog about Python from the view point of Jarno Virtanen.
In the core of TDD, if I understand it correctly, is a cycle of 1)
writing the unit test 2) writing a minimal implementation that passes
the test and 3) refactoring the code, if necessary. Thus the mantra
goes like this: you can safely refactor the code, since the unit tests
(or "regression tests") make sure that you can see if the existing
code breaks. In TDD, refactoring is constantly necessary,
because writing a minimal implementation might just imply, for
example, writing a method that returns a constant string that the test
case is expecting. Most often this is not the functionality that the
method should ultimately provide.
Now, the essentially black-box testing method, writing the tests
before the code, does not guarantee that the existing code does not
break when you refactor, because with unit testing in general you
cannot find but a fraction of all bugs. So I do not claim that you
cannot produce high-quality software with test-driven development, but
I do claim that the mantra about the cycle, "you can safely refactor
since the unit tests guarantee that you do not introduce bugs", is not
accurate. I do not know what that implies. Presumably, TDD
advocates say it does not mean anything.
In this issue, I am perfectly willing to accept that I just
misunderstood something fundamental here.