Test::MockDBI 0.62 has been released and will be available for download from CPAN shortly. Test::MockDBI mocks up the entire DBI API, and gives complete control of DBI return values and database-returned data.

The most important changes in version 0.62 include:

SAMPLE USAGE:
# tmd.t use strict; use warnings; # Enable testing with Test::MockDBI BEGIN { push @ARGV, "--dbitest"; } use Test::More; use Test::MockDBI qw( :all ); plan tests => 4; my $md = Test::MockDBI::get_instance(); my $dbh = DBI->connect("", "", ""); # Set of return values for given sql query my $aref_of_hrefs = [ { name => 'Huey', instrument => 'cello' }, { name => 'Dewey', instrument => 'trombone' }, { name => 'Louie', instrument => 'piano' }, ]; $md->set_retval_scalar( MOCKDBI_WILDCARD, "select name, instrument from nephews", sub { shift @$aref_of_hrefs } ); # Execute the sql query and fetch results $dbh->prepare("select name, instrument from nephews"); is_deeply( $dbh->fetchrow_hashref(), { name => 'Huey', instrument => 'cello' }, q{Expect Huey on the cello} ); is_deeply( $dbh->fetchrow_hashref(), { name => 'Dewey', instrument => 'trombone' }, q{Expect Dewey on the trombone} ); is_deeply( $dbh->fetchrow_hashref(), { name => 'Louie', instrument => 'piano' }, q{Expect Louie on the piano} ); ok(!$dbh->fetchrow_hashref(), q{Expect no more than 3 rows}); __END__
Expected output:
$ perl tmd.t 1..4 ok 1 - Expect Huey on the cello ok 2 - Expect Dewey on the trombone ok 3 - Expect Louie on the piano ok 4 - Expect no more than 3 rows $ prove tmd.t tmd....ok All tests successful. Files=1, Tests=4, 0 wallclock secs ( 0.07 cusr + 0.01 csys = 0.08 C +PU)
Thanks to Mark Leighton Fisher for handing out commit bits.
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

In reply to Test::MockDBI 0.62 released by andreas1234567

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.