Test::DatabaseDatabase handles ready for testing | |
Download |
Test::Database Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Philippe Bruhat
- Publisher web site:
- http://search.cpan.org/~book/
Test::Database Tags
Test::Database Description
Database handles ready for testing Test::Database is a Perl module that provides a simple way for test authors to request a test database, without worrying about environment variables or the test host configuration.SYNOPSISMaybe you wrote generic code you want to test on all available databases: use Test::More; use Test::Database; # get all available handles my @handles = Test::Database->handles(); # plan the tests plan tests => 3 + 4 * @handles; # run the tests for my $handle (@handles) { diag "Testing with " . $handle->dbd(); # mysql, SQLite, etc. # there are several ways to access the dbh: # let $handle do the connect() my $dbh = $handle->dbh(); # do the connect() yourself my $dbh = DBI->connect( $handle->connection_info() ); my $dbh = DBI->connect( $handle->dsn(), $handle->username(), $handle->password() ); }It's possible to limit the results, based on the databases your code supports: my @handles = Test::Database->handles( 'SQLite', # SQLite database { dbd => 'mysql' }, # or mysql database { driver => 'Pg' }, # or Postgres database ); # use them as aboveIf you only need a single database handle, all the following return the same one: my $handle = ( Test::Database->handles(@requests) ); my ($handle) = Test::Database->handles(@requests); my $handle = Test::Database->handles(@requests); # scalar context my $handle = Test::Database->handle(@requests); # singular! my @handles = Test::Database->handle(@requests); # one or zero itemYou can use the same requests again if you need to use the same test databases over several test scripts. Requirements: · Perl
Test::Database Related Software