NAME

Fennec::DeveloperManual::TBAssertions - Using Test::Builder based tools with Fennec.

THEY JUST WORK

package MyTest;
use Fennec asserts => [];
use Test::More;

ok( 1, "pass w/ Test::Builder" );

tests grouped {
    ok( 1, "still used Test::Builder" );
}

# This is Fennecs, not Test::Mores.
# That means you can use TB tools in standalone as well.
done_testing;

1;

'THEY JUST WORK' CAVEATS

Result and diag disconnect

Fennec overrides Test::Builders diag() and ok() methods. As such results and diag appear in the order they are generated. Diag's are often displayed well before the result they are for. This is not much different then TB tools outside fennec.

Using 'wrapped' Test::Builder tools groups diag and results together. When they are available you should use the wrapped tools. Wrapped tools also provide better diagnostics messages in addition to the norm.

THEY WORK BETTER WRAPPED

This is how Fennec wraps Test::Warn in version 0.17

package Fennec::Assert::TBCore::Warn;
use strict;
use warnings;

use Fennec::Assert;
use Fennec::Output::Result;
require Test::Warn;

our @LIST = qw/warning_is warnings_are warning_like warnings_like warnings_exist/;

for my $name ( @LIST ) {
    no strict 'refs';
    next unless Test::Warn->can( $name );
    tester $name => tb_wrapper \&{ 'Test::Warn::' . $name };
}

1;

Fennec loads Test::Warn, it then iterates a list of functions Test::Warn provides. It first checks that the loaded version of TesT::More implements the function. When it finds a function that is implemented it will wrap it using tb_wrapper. The wrapped function is then exported using the standard Custom Assertion utilities. See Fennec::Manual::Assertions for mroe details.

ADVANTAGES OF WRAPPING

Result and diag are grouped

Diags produced will be grouped with the result in a verbose harness, this is the fennec way.

More likely to work

Fennecs system of overriding diag() and ok() within Test::Builder is not foolproof. It is not out of the realm of possibility for Test::Builder based tools to bypass this system. If there is a wrapped form of the tool you want then there is a higher chance these edge cases have been weeded out by the author of the wrapped version.

WRAPPED CORE

If you would rather use TB based assertions rather than the ones Fennec implements, Fennec provides wrapped forms of the 4 main TB tools. Test::Simple, Test::More, Test::Warn and Test::Exception. You can load them all at once using the Fennec::Assert::TBCore module:

use Fennec asserts => [ 'TBCore' ];

Or you can load them individually:

use Fennec asserts => [ 'TBCore::Simple' ];
use Fennec::Assert::TBCore::More;
use Fennec::Assert::TBCore::Warn;
use Fennec::Assert::TBCore::Exception;

USER DOCUMENTATION

User documentation is for those who wish to use Fennec to write simple tests, or manage a test suite for a project.

Fennec::UserManual

DEVELOPER DOCUMENTATION

Developer documentation is for those who wish to extend Fennec, or contribute to overall Fennec development.

Fennec::DeveloperManual

API DOCUMENTATION

API Documentation covers object internals. See the POD within each individual module.

AUTHORS

Chad Granum exodist7@gmail.com

COPYRIGHT

Copyright (C) 2010 Chad Granum

Fennec is free software; Standard perl licence.

Fennec is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.