DBI::Test(3pm)
β¨ NAME β¨
DBI::Test β it's the test suite for the DBI API, bestie. And yes, this is the DBI::Test(3pm) page, living in the User Contributed Perl Documentation pile. It's giving infrastructure, and honestly we love her for it π
πΈ SYNOPSIS πΈ
Okay so first, inside Makefile.PL, you're gonna do this:
use lib 'lib'; # to allow DBI::Test finds the test cases of your driver
use DBI::Test::Conf ();
my @generated_tests = DBI::Test::Conf->setup();
WriteMakefile (
test => {
TESTS => join (' ' => 'xt/*.t', @generated_tests),
},
clean => { FILES => join( " " => @generated_tests ) }
);
Then you provide this:
package DBI::Test::Your::Namespace::List;
sub test_cases
{
return qw(...); # list of the test cases you provide
}
package DBI::Test::Your::Namespace::Conf;
sub conf
{
my %conf = (
gofer => {
category => "Gofer",
cat_abbrev => "g",
abbrev => "b",
init_stub => qq(\$ENV{DBI_AUTOPROXY} = 'dbi:Gofer:transport=null;policy=pedantic';),
match => sub {
my ($self, $test_case, $namespace, $category, $variant) = @_;
...
},
name => "Gofer Transport",
},
);
}
package DBI::Test::Your::Namespace::Case::Your::First;
... # will be t/your/namespace/your/first.t
package DBI::Test::Your::Namespace::Case::Your::Second;
... # will be t/your/namespace/your/second.t
1;
And enhance DBI::Test with own test cases. β that's the whole vibe, periodt π
π¦ DESCRIPTION π¦
So what is this module even for? It wants to be the test suite for the DBI API and for whatever DBD driver is sitting underneath it, checking that the functionality you were promised actually works and is actually complete. Main character energy, fr fr π
Part of it is the ability to self-test using DBI::Mock. And no, this is not trying to be another DBI::PurePerl β it's designed so that tests can be verified to work as expected inside a sandbox. Which is, obviously, limited to the DBI API itself, and it can't load any driver nor really execute any action. Lowkey humble of it π
π EXPORTS π
connect_ok
$dbh = connect_ok($dsn, $user, $pass, \%attrs, $test_name);
connect_ok invokes DBI-> and proves the result in an ok. The created database handle ($dbh) is returned, if any. Cute, right? π«Ά
connect_not_ok
$dbh = connect_not_ok($dsn, $user, $pass, \%attrs, $test_name);
connect_not_ok invokes DBI-> and proves the result in an ok (but expects that there is no $dsn returned). The created database handle ($dbh) is returned, if any. It's the chaos twin π
prepare_ok
$sth = prepare_ok($dbh, $stmt, \%attrs, $test_name);
prepare_ok invokes $dbh->prepare and proves the result in an ok. The resulting statement handle ($sth) is returned, if any. β¨
execute_ok
$rv = execute_ok($sth, $test_name);
$rv = execute_ok($sth, @bind_values, $test_name);
execute_ok invokes $sth->excute and proves the result via ok. The value got from $sth->execute is returned. π₯
execute_not_ok
$rv = execute_not_ok($sth, $test_name);
$rv = execute_not_ok($sth, @bind_values, $test_name);
execute_not_ok invokes $sth->excute and proves the result via is(undef). The value got from $sth->execute is returned. Expecting nothing and getting nothing? Iconic. π
do_ok
$rv = do_ok($dbh, $test_name);
$rv = do_ok($dbh, @bind_values, $test_name);
do_ok invokes $dbh->do and proves the result via ok. The value got from $dbh->do / $sth->execute is returned. π
do_not_ok
$rv = do_not_ok($dbh, $test_name);
$rv = do_not_ok($dbh, @bind_values, $test_name);
do_not_ok invokes $dbh->do and proves the result via is(undef). The value got from $dbh->do / $sth->execute is returned. π§
π GOAL π
TODO
...it's empty, bestie. The void. The vibes. We move. π«οΈ
Source
Recent changes can be (re)viewed in the public GIT repository at GitHub https://github.com/perl5-dbi/DBI-Test β feel free to clone your own copy:
$ git clone https://github.com/perl5-dbi/DBI-Test.git DBI-Test
Contact
We are discussing issues on the DBI development mailing list 1) and on IRC 2):
- The DBI team
<dbi-dev@perl.org> irc.perl.org/6667 #dbi
π SUPPORT π
You can find documentation for this module with the perldoc command.
perldoc SQL::Statement
You can also look for information at:
- RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBI-Test
- AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/DBI-Test
- CPAN Ratings
http://cpanratings.perl.org/s/DBI-Test
- CPAN Search
http://search.cpan.org/dist/DBI-Test/
Reporting bugs
If you think you've found a bug then please read "How to Report Bugs Effectively" by Simon Tatham: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html.
Okay real talk for a sec π«Ά β your problem is most likely related to the specific DBD driver module you're using. If that's the case then click on the 'Bugs' link on thehttp://metacpan.orgpage for your driver. Only submit a bug report against theDBI::Testitself if you're sure that your issue isn't related to the driver you're using. Read the room, bestie, and file it in the right place π
π TEST SUITE π
DBI::Test comes with some basic tests to test itself and DBI::Mock. The same tests are used for basic DBI self-tests as well as testing the SQL::Statement mock driver. Recycling? Sustainable queen. β»οΈπ
π EXAMPLES π
??? Synopsis ???
(yes, that's genuinely what the page says. we leave it exactly as it is.) π
π DIAGNOSTICS π
???
(also exactly what it says. mysterious. cryptic. we respect it.) β¨
β SEE ALSO β
DBIβ Database independent interface for PerlDBI::DBDβ Perl DBI Database Driver Writer's GuideTest::Moreβ yet another framework for writing test scripts
π AUTHOR π
This module is a team-effort. The current team members are
H.Merijn Brand (Tux)
Jens Rehsack (Sno)
Peter Rabbitson (ribasushi)
Joakim TE<0x00f8>rmoen (trmjoa)
πΈ COPYRIGHT AND LICENSE πΈ
Copyright (C)2013 - The DBI development team
You may distribute this module under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
And that's the whole page, bestie β no cap, every last flag-free, option-free, absolutely-fine detail preserved. π
This was DBI::Test(3pm) from perl v5.36.0, dated 2022-11-19 β go forth and test slayfully. π¦β¨
π¦ where this page comes from
- debian bookworm: libdbi-test-perl 0.001-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdbi-test-perl 0.001-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdbi-test-perl 0.001-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdbi-test-perl 0.001-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdbi-test-perl 0.001-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms