logo       

Re: Possible FAQ answer (Re: Multiple Test Cases): msg#00191

java.junit.user

Subject: Re: Possible FAQ answer (Re: Multiple Test Cases)

> > > 1.Do we need to create a Test-case class for every
> > > class we need to test.
> >
> > No. It is a convention to start with one TestCase class per class under
> > test, but it is not necessary.
> >
> > TestCase classes only provide a way to organize tests, nothing more.
> > Generally you will start with one TestCase class per class under test, but
> > then you may find that a small group of tests belong together with their
> > own
> > common test fixture.[1] In this case, you may move those tests to a new
> > TestCase object.
>
> Do not forget maintenance: keep tests easy to find.

Of course.

> - myClass -> myClassTest since everybody expect a test class per
> class

...since everyone expects *at least* a test case per class. I don't recommend
naming things poorly; I do recommend not limiting yourself to one test case
per class because "somebody said so." If you need three, write three, but
make them easy to find.

> - add a comment in myClassTest.java file to specify where
> other relevant tests for this class are located.

Absolutely. This is one of the few times that comments are worthwhile. Even
better (I think) is to add a suite() method to XTest that contains all the
suites that test X.

> There's no rule here just common sense.

As (almost) always.

--
J. B. Rainsberger,
President, Diaspar Software Services
Let's write software that people understand.
http://www.diasparsoftware.com/
telephone: +1 416 791-8603



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise