unit testing

byte8bits at gmail.com byte8bits at gmail.com
Fri Oct 5 10:12:45 EDT 2007


On Oct 5, 5:38 am, Craig Howard <craig.how... at earthlink.net> wrote:
> Brad:
>
> If the program is more than 100 lines or is a critical system, I
> write a unit test. I hate asking myself, "Did I break something?"
> every time I decide to refactor a small section of code. For
> instance, I wrote an alarm system in Python for a water treatment
> plant. If the chlorine, pH, or turbidity are out of spec, an email
> message is sent to the plant operator's pager. Because of the nature
> of the alarm system, extensive field testing was out of the question.
> Unit testing was the only way to ensure it worked without disrupting
> the plant operation.
>
> Craig

Thanks to all for the opinions. Just to clarify, I have nothing
against testing. I like doing it. I catch a lot of bugs! I dislike the
formality of the unittest module. It's unyielding. It makes testing
difficult unless your code is written with testing in mind from the
start.

I maintain old code... code written a long time ago, before unittest
was popular. Getting unittest to work on that is difficult at best. So
we do informal testing ourselfs. The end result is the same... bugs
are squashed before the code is placed into production. Many times, we
find bugs as soon as we write a test!

Thanks again for the advice.

Brad





More information about the Python-list mailing list