MyTAP Integration

So you’ve caught the database testing bug and now you want to integrate MyTAP tests into your project’s test suite. Excellent. You’ve come to the right place. Just find your favorite programming language below and follow along. Don’t see your language here yet? If you figure out how to do it, please send us the instructions!

Perl

Chances are, if you’re writing Perl applications, you’re already using Test::More and Test::Harness to write and run your tests. If you use Module::Build to build your application, here’s how to hook in MyTAP tests so that they run right along with your Perl tests.

Requirements

Instructions

    BEGIN;
    SELECT tap.plan( 1 );
    SELECT tap.pass('W00t!');
    CALL tap.finish();
    ROLLBACK;
    use strict;
    use warnings;
    use Module::Build::DB;    

    Module::Build::DB->new(
        module_name        => 'My::App,
        test_file_exts     => [qw(.t .my)],
        configure_requires => {
            'Module::Build => '0.36',
        },
        build_requires     => {
            'Module::Build                      => '0.36',
            'TAP::Parser::SourceHandler::MySQL' => '3.22',
        },
        tap_harness_args => {
            sources => {
                Perl  => undef,
                MyTAP => {
                    database => 'try',
                    username => 'root',
                    suffix   => '.my',
                },
            },
        },
    )->create_build_script;

What this does is tell Module::Build to use TAP::Harness to run tests, rather than Test::Harness, and it tells it to use the MyTAP source handler to run tests with file names ending in “.my”.

    ./Build test
    t/perl.t......ok
    t/mytap.my....ok
    All tests successful.
    Files=2, Tests=6,  0 wallclock secs ( 0.03 usr  0.01 sys +  0.03 c 0.02 csys =  0.09 CPU)
    Result: PASS

Support for running MyTAP tests with ExtUtils::MakeMaker is planned, as well. Just bug Schwern to commit the patch and release a new version!

PHP

We’re sure there’s a way to integrate MyTAP tests with PHPUnit or SnapTest. If you figure it out, please send the instructions to the pgtap-users mail list and we’ll add them to this page!

Python

We’re sure there’s a way to integrate MyTAP tests with PyUnit. Certainly with PyTAP. If you figure it out, please send the instructions to the pgtap-users mail list and we’ll add them to this page!