Author image Masakazu Ohtsuka
and 1 contributors


App::Prove::Plugin::MySQLPool - pool of Test::mysqld-s reused while testing


    prove -j4 -PMySQLPool t
    prove -j4 -PMySQLPool=MyApp::Test::DB t


App::Prove::Plugin::MySQLPool is a prove plugin to speedup your tests using a pool of Test::mysqlds.

If you're using Test::mysqld, and have a lot of tests using it, annoyed by the mysql startup time slowing your tests, this module is for you.

This module launches -j number of Test::mysqld instances first.

Next, each mysqld instance optionally calls

    MyApp::Test::DB->prepare( $mysqld );

You can CREATE TABLEs using GitDDL or DBIx::Class::Schema::Loader or others, or bulk insert master data before start testing.

MyApp::Test::DB only needs to implement a prepare sub. prepare is called only once per -j number of mysqld instances, and is called before your first .t file get tested.

    # MyApp::Test::DB
    sub prepare {
        my ($package, $mysqld) = @_;
        my $gd = GitDDL->new( dsn => $mysqld->dsn, ... );

Use $ENV{ PERL_TEST_MYSQLPOOL_DSN } like following in your test code.

    my $dbh = DBI->connect( $ENV{ PERL_TEST_MYSQLPOOL_DSN } );

Since this module reuses mysqlds, you'd better erase all rows inserted at the top of your tests.

    $dbh->do( "TRUNCATE $_" ) for @tables;


Masakazu Ohtsuka <>


prove, Test::mysqld


This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.