Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Reusing tests against multiple databases

by astroboy (Chaplain)
on Apr 22, 2010 at 23:42 UTC ( #836366=perlquestion: print w/replies, xml ) Need Help??
astroboy has asked for the wisdom of the Perl Monks concerning the following question:

Hi there

I have some tests that need to run against multiple database products (SQLite, MySQL and Oracle), and am trying to determine the best way to organise them so that the tests can be reused. How does everyone else do this?

Here's an approach that I figured might work: I could use Test::Class and in my base class I'd create the schema/database in a startup method, and then I'd remove it in the shutdown method. My test classes would inherit from the base class. But what's the best approach to tell the startup and shutdown methods which vendor-related ddl scripts to run?

Advice appreciated.

  • Comment on Reusing tests against multiple databases

Replies are listed 'Best First'.
Re: Reusing tests against multiple databases
by GrandFather (Sage) on Apr 23, 2010 at 01:17 UTC

    I have a bunch of code I run tests against for SQLite and MySQL databases. I simply pass the DBI connect parameters into a test routine that opens the DB handle and runs the tests against it (in fact it actually passes the parameters through to an object constructor, but same difference).

    If you need special processing for the individual database engines shouldn't that be handled by the code under test? If not then add the handling for that to the test code.

    True laziness is hard work

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://836366]
Approved by AnomalousMonk
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2018-06-20 18:14 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.