[TIP] A rare philosophical thought
noah.gift at gmail.com
Fri Aug 1 17:14:48 PDT 2008
On Fri, Aug 1, 2008 at 1:28 PM, C. Titus Brown <ctb at msu.edu> wrote:
> So, I just posted a reply to someone new (or returning) to Python,
> and one of his complaints was this:
> The Python gurus recommend unit testing to make sure code is solid.
> That's great. If I wanted to write dozens of lines of boilerplate
> code in order to make sure stuff worked, I'd have stuck with C++. I want
> to write less code and be confident in the belief that that code is
> correct and error free.
One interpretation of this comment could be literal. I hate passionately
the syntax of the standard library unit test framework. For me, it is
indeed, a bunch of boilerplate code, with a Shakespearean English API. All
of this, "Where for art though equality..." stuff, is a bit annoying to me.
What is wrong with a plain assert?
What makes unit test worst is that people often make custom unit test
frameworks that involve non-trivial level of abstraction. I guess I feel
like this defeats part of the purpose of testing, which is to show someone
how your code work, not design yet another OO masterpiece. Personally I
really like doctest because, while it isn't perfect, it is simple, and easy
Maybe I am completely misunderstanding what he is complaining about though.
> My response was this:
> Your take on unit testing seems just plain wrong. I know of no useful
> language that can prevent the majority of programming errors without
> some form of actually running the code, a.k.a. "testing". You might
> think YMMV, but you're almost certainly wrong.
> For some reason, this was the first time I'd really thought of things
> this way: "testing" is really just "running the code", under actual or
> likely-to-be actual circumstances. The quality of your test effort can
> be measured by how reflective it is of the actual circumstances under
> which the code will be used, and the cost of the mismatches.
> C. Titus Brown, ctb at msu.edu
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python