begin  quoting Tracy R Reed as of Mon, Aug 14, 2006 at 12:56:48AM -0700:
> 
[snip]
> Unit tests? It's already written so I don't know if that would serve
> much point. I'm not sure how I would written implemented unit tests to
> begin with.
[snip]

Regression testing. Putting a framework of testing in place is a good
way to verify bugs... when a bug report comes in, you write a test that
would recreate the indicated problem.

As for writing unit tests... often, you look for a framework, but that's
not really necessary -- a directory of scripts that use your code can do
the same job.  Your "framework" can be "make", as far as that goes. :)

For each function you define, you create the appropriate environment,
create the input data set if any, make the call, and check the output
and changes to the environment.  This can get painful if side-effects
are relied on -- but you're playing with functional programming now,
so you should be minimizing the side-effects by habit, yes?

It also helps with some of the OO viewpoints -- instead of passing in
a string parameter that contains a filename, you can pass in a file
object (or better yet, a stream).  That way your unit tests can pass
in an instrumented object, and your production code doesn't have to.

It's _hard_ to insert unit-testing after the fact, as the design and
implementation of code that wasn't designed to be tested is, oddly
enough, difficult to test.

-- 
_ |\_
 \|

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to