Francisco,
Personally I like to have tests that depend upon one another in a single file. However, that is not always possible or easy to do. In your case though, I would suggest you use mock objects for your database instead of a real database. This would allow your tests to be run independent of one another since they would not rely on the database's current state, but instead on properly a configured mock-database.
I am not sure how familiar you are with mock objects, but I have found this to be an excellent resource: http://mockobjects.com/wiki/ although somewhat skewed towards Java. In addition, creating a mock-database can be done with DBD::Mock, which is available on CPAN. I have used DBD::Mock myself for the testing of a large database dependent application and found it much easier to test the database this way.
Hope this helps.
Steve
On May 25, 2004, at 1:58 PM, Francisco Olarte Sanz. wrote:
1st of all, thanks everyone for the prompt response regarding my previous question about return values.
Now a style question. I'm doing a database oriented module, and I have rouhly the following tests:
1.- Test wether module can load ( just a require inside an eval ).
2.- Test a bunch of functions for string processing (escaping) etc.. which don't need server connections.
3.- Test connection to the database.
4.- Create a test database, connect to it
5.- Create test tables, populate them, testing insertion functions on the way.
6.- Lots of tests which need the test database.
7.- drop test database.
I have 1 in a file, 2 split in several. 3 can be put in it's own file, but the problems arrive with steps 4-7. Steps 5 and 6 are lengthy, and I'd like to split them into several files, giving files 4, 5a, 5b, 5c, 6a, 6b, 6c..6z, 7 but in this case steps 4-7 should be run to completion. This goes against the recomendation of having tests which can be run separately ( and takes slightly longer as i need to reconnect on each test, but tests don't need to be so efficient). So I'm now putting 4- in a single file, but it's becoming huge ( hundreds of tests ). My question is..
¿ Which aproach is better, have a single independent huge test file or several interdependent smaller ones ( w/ notes in the readme stating test dependence ) ?
Regards. Francisco Olarte Sanz.