[melbourne-pug] Unit Testing (Following up TDD presentation)

Bruce Cropley cropleyb at yahoo.com.au
Fri Sep 2 03:30:37 CEST 2005

> From: Maurice Ling <mauriceling at acm.org>
> Hi all,
> Following from Bruce's presentation, I've been using
TDD mainly on the new codes I'm writing. Are there any
advice from the group for handling old codes that I've
written but needs modification?
> Thanks
> Maurice

I'm glad to hear you're giving it a go!

You could try writing a test for the functionality
that you are finding needs to be added.

Quite often you find that you want to write a unit
test, but it isn't possible because of a dependency in
that module that brings in a huge amount of the rest
of the system. So then you want some unit tests to
ensure you don't break stuff as you refactor that code
to reduce the coupling. But you can't because of those
same dependencies. etc...

For some domains, system tests are fairly easy to
write for older code, and they give you more
confidence that everything is working together
properly. Unfortunately, they run much slower than
unit tests. But you probably need some system tests

Another approach would be to try mocking out the
unwanted module dependencies. I've been adding
module/package mocking support to Dave Kirby's
Python-Mock project
Version 0.2 is coming out soon. It's still very early
days for the module mocking functionality, but the
main Mock class has been around for about 5 years. Let
me know if you try it out.

BTW, I've uploaded the presentation file and the
source that we wrote to the MPUG wiki



Do you Yahoo!? 
The New Yahoo! Movies: Check out the Latest Trailers, Premiere Photos and full Actor Database. 

More information about the melbourne-pug mailing list