DBI::Test(3pm)

πŸ“¦
version 0.001 Β· 2 versions
  • 0.001 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.001 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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):

  1. The DBI team <dbi-dev@perl.org>
  2. 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 the http://metacpan.org page for your driver. Only submit a bug report against the DBI::Test itself 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 Perl
  • DBI::DBD β€” Perl DBI Database Driver Writer's Guide
  • Test::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 (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