Many Test classes or one Test class with many methods?

Viewed 10311

I have a PersonDao that I'm writing unit tests against.

There are about 18-20 methods in PersonDao of the form -

    getAllPersons() 
    getAllPersonsByCategory()
    getAllPersonsUnder21() etc

My Approach to testing this was to create a PersonDaoTest with about 18 test methods testing each of the method in PersonDao

Then I created a PersonDaoPaginationTest that tested these 18 methods by applying pagination parameters.

Is this in anyway against the TDD best practices? I was told that this creates confusion and is against the best practices since this is non-standard. What was suggested is merging the two classes into PersonDaoTest instead.

As I understand is, the more broken down into many classes your code is, the better, please comment.

5 Answers
Related