logo       

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

java.junit.user

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

J. B. Rainsberger wrote:

>>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. This is a simple object-oriented refactoring: separating
>responsibilities of an object that does too much.
>
>Another point to consider is that the TestSuite is the smallest execution
>unit in JUnit: you cannot execute anything smaller than a TestSuite at one
>time without changing source code. In this case, you probably do not want to
>put tests in the same TestCase class unless they somehow "belong together".
>If you have two groups of tests that you think you'd like to execute
>separately from one another, it is wise to place them in separate TestCase
>classes.
>
>[1] A test fixture is a common set of test data and collaborating objects
>shared by many tests. Generally they are implemented as instance variables in
>the TestCase class.
>

Good stuff!

May I add it to the FAQ?

Mike


[Non-text portions of this message have been removed]




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

News | FAQ | advertise