I've struggled with this exact problem for my recent releases of
Class::Tables. Its test requires a working MySQL or SQLite datasource, which is filled up with some sample data to test the module's interface. You can check out the source of my Makefile.PL and test.pl to see how I get the module's build process to configure the test datasource. When developing my test suite, I searched CPAN for
DBIx::* modules and borrowed (stole) a lot of ideas from those that had test suites (can't remember exactly which ones).
DBD::mysql also has quite an extensive test suite, so you have a few places to start looking.
Here's the very rough outline of what I do for my tests: (I'd also be interested to know if this isn't the Right Way to do it)
- MakeFile.PL prompts for database connection info, and then saves it in a ./testconfig/Config.pm file using Data::Dumper. You should provide some mechanism to change the configuration (I use the -s option to MakeFile.PL). You may also want to provide an option to skip the tests here.
- test.pl loads the Config.pm file to get the connection information. If the user has decided to skip the tests, or we couldn't connect to the database, you may want to skip_all of your tests. If we could connect, then test.pl empties out all the tables from this database and inserts the test data manually with SQL statements.
That's the basic outline, but I think rather than getting into much more detail, you should look at/steal from other test suites that fit your goals. Hope this helps!
*: Update: Just looked through my browser history: DBIx::FullTextSearch is one of the DBIx:: modules I used as a test template.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.