Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The most obvious and most commonly used is the surrogate DBD testing. This is where the author of a module tests the connection to a database, through DBI and a DBD driver, to ensure that they can process queries. I have often asked why?

It is often very hard to make sure a module really works with a mock object as you're suggesting. After all, your SQL can be exactly what you're expecting and still be wrong.

One module I've found which is very helpful is DBD::AnyData, formerly called DBD::RAM. It can create an in-memory database and run simple SQL queries. Unfortunately, it's become somewhat bloated; it also handles CSV, XML, and a lot of other formats, as well as acting as a sort of adapter between different data sources. (Personally, I'd prefer they all be split out into different DBDs with a common backend...) Still, I'm making my module suggest installing it for testing, and then use it if the user doesn't provide a real database in environment variables.

I would love it if DBI shipped with a DBD::Perl which would create a database in a hash (hash of arrays of arrays, probably). You could insert data through SQL and then check it manually, or vice versa. This would allow you to test without disturbing the user's database server and in a way that would avoid you making the same mistake twice.

(Yes, I'm aware of DBD::Sponge. It's bizarre and unsuitable for a test suite where you're trying to test standard code, not special code designed for that DBD.)

=cut
--Brent Dax
There is no sig.


In reply to Re: Trojan Perl Distributions by BrentDax
in thread Trojan Perl Distributions by barbie

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-20 15:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found