Re: unit testing practices...
Peter Donald <peter-4lf8KW9E9MLMqX/[email protected]>
| Newsgroups | gmane.comp.java.jcontainer.interest |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 5 Nov 2003 02:48 pm, peter royal wrote:
> started playing with clover, trying to get test coverage up before
> hacking things up to support funky things with components.. using
> clover a guide to know when "done" ...
sweet!
> is it standard practice to also test exception blocks? for instance,
> Assembler is fully covered, except for the catch blocks. should I feed
> it known bad data just to exercise these?
I generally do. However the unit tests that are in phoenix atm are really
really badly done ;) ie each unit test tends to test lots more than what it
saids and it can be easy to miss tes coverage if you use such broad brush
strokes.
What I tend to do now is have really small unit tests that just test a single
method and all its purmutations (including error conditions). I encode the
data in the test case and dont bother with external files at all. ie XML
input is encoded in strings and only really used to test parsing.
I just commited a small test case for assembler to show you the type of tests
I tend to write. If you want to see more examples check out either the qdox
or metaclass codebases for similar examples.
Anyways - thats what I consider good coding practices
--
Cheers,
Peter Donald
USER, n.:
The word computer professionals use when they mean "idiot."
-- Dave Barry, "Claw Your Way to the Top"