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]