[TIP] best strategy for retrofitting code with unit tests
fuzzyman at voidspace.org.uk
Mon Mar 5 14:43:06 PST 2007
Nate Lowrie wrote:
> Ok, I have done a couple of small - medium sized projects through a
> TDD cycle and have been successful at it. Now, we are trying to
> retrofit a large framework (Dabo) with unit tests. It's a 3 tier
> framework with an agnostic db layer, business object/logic layer, and
> a UI layer that currently wraps WxPython.
> What is the best strategy for this? Should we just adopt a TDD for
> all new code and do a refactor/red/green cycle on the existing code as
> the new code comes in? Should we unit test the business layer only
> and resign to acceptance testing on the other 2?
NB I've not had to *do* this, so my suggestion is theoretical only.
I would add acceptance tests for the higher levels as soon as you can.
I would add unit tests for code as you refactor, but apply this to all
the layers. That should eventually get you pretty good coverage.
It is more a difficulty if you just want to retrofit tests without
actually needing to touch a lot of the other code - but at least this
approach will get you off the ground and you can review it.
More information about the testing-in-python