On Fri, Jan 15, 2010 at 3:47 PM, Phlip <phlip2...@gmail.com> wrote: > Victor Subervi wrote: > > > Should I re-write it in classes before testing units? Right now it's > > very monolithic. > > The "Unit" in unit tests is a misnomer. It refers to an old QA concept, for > high-end projects, that the failure of any test should implicate only one > unit. > > We only need "developer tests". They help, when we change the code, to > avoid excessive debugging. And to test a given method you must be able to > access it, so tests force your code to be decoupled. But a test may call as > many functions as it needs, regardless what "unit" they live in. > > If you don't have tests yet, then sometimes a rewrite is indicated (and > sometimes it's very easy and will produce _very_ clear code!). But in most > cases like yours the best advice is to write your next feature using "test > driven development". Write the test first, get it to fail, then change the > code as little as possible to get it to pass. Repeat until done, > occasionally refactoring. > > If old code now works, just leave it alone. Until it needs a new feature, > and then wham! it has tests. >
:) k. Thanks beno
-- http://mail.python.org/mailman/listinfo/python-list