Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Testing a DBI module

by Thilosophy (Curate)
on Jan 24, 2005 at 02:29 UTC ( [id://424482]=note: print w/replies, xml ) Need Help??


in reply to Testing a DBI module

Maybe DBD::Mock can help you. It does not connect to any real database, but just traces all the SQL you issue, so that you can later check if that is what you wanted.

Maybe you want to have a look at DBD::SQLite. While it does not exist everywhere, it is easy to install anywhere because it contains its own DBMS.

You could have some tests that only run if DBD::SQLite is present (using a temporary file for your test DB).

You can also have the user set the DBI connect string via an environment variable if he wants to run the tests against his real database. These tests will be skipped in automated testing, but at least they can run them after reading your README if they want.

Replies are listed 'Best First'.
Re^2: Testing a DBI module
by grinder (Bishop) on Jan 24, 2005 at 11:16 UTC
    It does not connect to any real database

    Excellent advice. This reminds me that it's probably worth raising the awareness of barbie's rant on DBI testing: Trojan Perl Distributions. If you haven't read that thread, then one should take a look at it now.

    - another intruder with the mooring in the heart of the Perl

Re^2: Testing a DBI module
by dragonchild (Archbishop) on Jan 24, 2005 at 14:33 UTC
    While it does not exist everywhere, it is easy to install anywhere because it contains its own DBMS.

    Assuming, of course, you have the same C compiler that was used to compile your version of Perl and you're on one of the systems that SQLite will work on. Remember - Perl works on over 200 different OSes. I'm pretty sure SQLite doesn't have the same claim. DBD::Mock is a much better choice.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://424482]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (1)
As of 2024-07-23 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.