My preferred why to do this is to use an in memory database (such as HSQLDB) for the tests. The database gets created at the start of the testrun and destroyed at the end. That way I don't have to care about bogus content at all. It's also relatively fast.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
To me it seemed as if the point was what to do with tests which require different setUp/tearDown requirements.
The "purist" approach is to say that a "test case" is defined by the setUp and tearDown menthods - so if two tests need different set ups then they should be in different test classes. In the case above this might look something like:
test class 1:
That was a bit wordy, but I hope it shows my point. Tests which assume a freshly created Empl go in one class. Tests which assume a container populated with some example Empl instances go in one class. Tests which assume no set up conditions because they are testing creation go in yet another class.
The important thing is to avoid assuming that all tests for one domain class should always go in one test case class.
I do not want to be picky Frank - just to point out something which relates to the original question. In the code above before each test is run the setUp() method adds records for 1 and 2. Therefore when testAddNew() is run, 1 and 2 exist, the test adds 3 and does its stuff. tearDown() then deletes everything (1 and 2 added by setUp() and 3 added by testAddNew()).
Before testAddDuplicate() runs, setUp() is run again and adds 1 and 2. Then testAddDuplicate() adds 3 once. IMHO in order to test whether duplicates are added you should have an extra line for add(3);. Then if duplicates are not allowed the assertEquals(3, whatever.count()) will validate that only three records were added when you attempted to add 4.
Hope this helps the original poster,
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.