Test::DBIx::Class::Stats - test statistics about your DBIx::Class calls
Run a subtest with a debugging object (Test::DBIx::Class::Stats::Profiler) set to capture the number of calls that have been made to the database. This may be useful to check your assumptions about prefetching, etc.
use Test::More; use Test::DBIx::Class::Stats; # if you are using Test::DBIx::Class or similar, we can get the # database handle from the `Schema` method use Test::DBIx::Class; with_stats 'test 1', sub { my $stats = shift; my $rs = Schema->resultset('Foo')->search(); is $stats->call_count, 0, 'No calls on preparing RS'; my @foo = $rs->all; is $stats->call_count, 1, '1 call after preparing RS'; }; # alternatively, we can pass it in explicitly: my $db = Schema with_stats 'test 2', $db, sub { ... };
with_stats $name, [$db], $code
The Test::DBIx::Class::Stats::Profiler object is created for the database and is passed to your code reference as its first and only argument.
If $db is not passed, the caller's Schema function will be called. This is designed to work with Test::DBIx::Class.
$db
Schema
osfameron <osfameron@cpan.org> 2014-2017 Alexander Hartmaier <abraxxa@cpan.org> 2017
To install Test::DBIx::Class::Stats, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::DBIx::Class::Stats
CPAN shell
perl -MCPAN -e shell install Test::DBIx::Class::Stats
For more information on module installation, please visit the detailed CPAN module installation guide.