Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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 romping around the Monastery: (4)
As of 2014-09-21 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls