Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Setting up database connection in tests

by sundialsvc4 (Abbot)
on Sep 13, 2012 at 14:57 UTC ( #993507=note: print w/ replies, xml ) Need Help??


in reply to Setting up database connection in tests

Certainly, since the testing frameworks are Perl programs, you should in those tests use a single module whose purpose is to establish the database-connection and to return the handles needed by all tests.   Once the module has been constructed and verified, it does not itself need to be the subject of a test.

As previously suggested, it can also be a “mock-up” which is known to consistently produce the same test-data.   You can even go one step further by designing a subroutine that returns a “letter-bomb $dbh.”   This returns an object that has the same necessary-for-your-app methods as a real database-handle, but which methods are contrived in some way to “blow up,” thereby predictably and consistently simulating error conditions without actually having to jimmy-up code that actually throws the desired error for any genuine reasons.


Comment on Re: Setting up database connection in tests

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2015-07-05 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls