Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993507]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2018-06-21 20:11 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (119 votes). Check out past polls.