Hi,

in a few days I want to put the first version of DBIx::Table::TestDataGenerator on CPAN. One of the issues I need to solve is how to provide meaningful tests. The module will try to support as many DBMSs as possible, currently Oracle and PostgreSQL are supported, there will be more and I try to make it easily extensible to other DBMSs I have not thought of. The tests I have currently written target Oracle and PostgreSQL, and to connect to the databases the tests pick up some environment variables. In case those variables are absent, they are asked from the user running 'build test'.

So, for interactively installing and running the tests, I am fine. But this obviously does not work when CPAN testers will run the tests.

Would it be feasible to bundle an SQLite database and run the tests against it in case no other database has been specified? I cannot think of a simpler database to test against, at least the thing would need to allow constraints such as primary and foreign keys as well as uniqueness constraints. I looked at DBD::Mock, but I don't see how this could help me since SQL code is not really being run against some sort of tables and one would need to mock the expected results too, which would not be a useful testing approach.

How would you handle such tests? I am sure not to be the first person to face this issue, but I could not yet find a good enough answer, e.g. when looking up the tests of other DBIx modules.

Update: Having had few experience with SQLite, after having read some documentation for DBD::SQLite, I was pleased to see how easy it is to create an in memory database, making it unnecessary to bundle a SQLite database with the module for testing purposes.


In reply to How to do automated tests of a database centric CPAN module by jds17

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.