in reply to Writing tests for modules using database handles
Make it possible to set up your program with a different database handle. In your test program, open a handle to a file or memory database with just enough test data to make things work.
I used DBD::CSV in a project, stuffed the applicable data after __DATA__, and wrote a small sub to dump things to a CSV file. Very simple:
sub make_db { open(OUT, '>page_data') or die "Can't open output db: $!"; while (<DATA>) { chomp; print OUT $_, "\015\012"; } close OUT; }
Depending on how tricky your SQL calls are, you may have to get more tricky here. Hmm, it would be good to have someone write a DBI testing module. Any takers?
|
|---|