commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [lang] Unit test coding conventions?
Date Mon, 08 Jul 2002 21:26:19 GMT
My preferred style for unit tests for this kind of low level utility code is
to write one test method per failure case and one test method for each
really distinct success case (which should just be one, otherwise the method
is doing two things and should be refactored). This results in multiple
asserts in the success test method, but this doesn't bother me. It's going
to work first time isn't it ;-)

I split out some of the Strings test classes into separate classes because I
am predicting the number of tests to get very large, and unmanageable in one
lump. This was partly why I reordered the Strings source file. My idea was
to create one test class for each group of methods in the Strings source
file. (Avoids one class per method and avoids one class for all the
methods). Please shout now if you think this is a bad plan!

Stephen

From: "Henri Yandell" <bayard@generationjava.com>
> On Fri, 5 Jul 2002 ringo.desmet@mediagenix.com wrote:
> > > I am against a test method only testing one case, but am for
> > > a test method
> > > testing only one target on the tested-class. Check
> > > CharSetTest where I am
> > > currently doing 5 tests per tested-class method.
> >
> > Still, don't you find it annoying that the first case could fail, that
you
> > fix it and on the subsequent test run another case fails? If you have a
test
> > method per case, you see *all* failures at once. This gives you better
> > insight on what you have to do to fix the set of failures instead of
> > focusing on one case at the time. More than once, I gained time having a
> > test method per case setup.
>
> Possibly. Seems a rather heavy setup. Could have hundreds of methods per
> test class.
>
>
> > > The build.xml's currently make us add a class each time.
> >
> > BTW, there are 4 different Strings test classes that test part of the
> > Strings API. Shouldn't we put all the tests in the StringsTest class?
>
> I suspect this is Stephen's preferred style. Will let him reply when he
> gets back.



--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message