doo...@apache.org wrote:
> Author: doogie
> Date: Mon Mar  1 05:07:00 2010
> New Revision: 917377
> 
> URL: http://svn.apache.org/viewvc?rev=917377&view=rev
> Log:
> BUG FIX: Move node test to before the loadClass call.

All done, except for one thing.

The original ObjectType.simpleTypeConvert had a java.nio.Buffer
conversion.  However, it was completely broken, and would never work.
 It only supported converting a Buffer to a ByteBuffer, and it did
that by casting, without even attempting to do any conversion; if a
CharBuffer was passed, it would throw a ClassCastException.

I have not implemented the Buffer conversions, because of this.  It
appeared to me that someone tried to add support, but never tested it.
 Since the original code would already do a straight pass-thru when
the source and target classes are the same, this particular problem
was never detected.

Which brings up another point.  simpleTypeConvert had an early test to
do straight passthru of same-type conversions.  This invalidated *any*
later test in each type block, that tried to test the target type
being the same.

I also discovered several other unreachable conditions.  An earlier
test would check if the input was a String, and was empty, and return
null.  Later checks that then tried to do something else when the
string was empty were never ran.

Code coverage helped me discover all these problems.  I was able to
make certain that every single line was tested, every single
condition.  The implementation of the tests also made some things get
tested multiple times, but that is perfectly fine.

Then, as normal, I redirected the test cases to the new
simpleTypeConvert.  Then, all problems were fixed in a single commit.
 And, as you have all seen, I fixed all the problems one by one.

I created all the tests cases yesterday(saturday).  Mid-evening I
started breaking them up, and had that done by 5pm.  I then went out
to hang with some friends, and committed when I was done.

I'd like to see others go thru and start *really* adding test cases.
Every single time I have added full coverage on some class, I have
*always* found something wrong.  Sometimes, it was just a simple
dead-code elimination.  Others, like this latest push, had many more
issues.

If there is no coverage on a class/method/line, then it is *not* being
tested.  So how can you be sure that the change you are thinking of
doing has any chance of working?  Even with full coverage, all you can
be certain is that your new code runs, and doesn't break any known
test cases.  It's still possible other things might break, but it's at
least better than nothing.

Reply via email to