GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TEST2::TOOLS (3)

.ds Aq ’

NAME

Test2::Tools - Documentation for Tools.

CONTENTS

EXPERIMENTAL RELEASE

This is an experimental release. Using this right now is not recommended.

DESCRIPTION

Tools are packages that export test functions, typically all related to a specific aspect of testing. If you have a couple different categories of exports then you may want to break them into seperate modules.

Tools shoudl export testing functions. Loading tools <B>should notB> have side effects, or alter the behavior of other tools. If you want to alter behaviors or create side effects then you probably want to write a Test2::Plugin.

FAQ

Why is it called Test2::Tools, and not Test2::Tool? This question arrises since Tools is the only namespace in the plural. This is because each Plugin should be a distinct unit of functionality, but a Tools dist can (and usually should) export several tools. A bundle is also typically described as a single unit, nobody would like Test2::Bundles::Foo.
Should my tools subclass Test2::Tools? No. Currently this class is empty. Eventually we may want to add behavior, in which case we do not want anyone to already be subclassing it.

HOW DO I WRITE A ’TOOLS’ module?

It is very easy to write tools:



    package Test2::Tools::Mine
    use strict;
    use warnings;

    # All tools should use the context() function.
    use Test2::API qw/context/;

    our @EXPORTS = qw/ok plan/;
    use base Exporter;

    sub ok($;$) {
        my ($bool, $name) = @_;

        # All tool functions should start by grabbing a context
        my $ctx = context();

        # The context is the primary interface for generating events
        $ctx->ok($bool, $name);

        # When you are done you release the context
        $ctx->release;

        return $bool ? 1 : 0;
    }

    sub plan {
        my ($max) = @_;
        my $ctx = context();
        $ctx->plan($max);
        $ctx->release;
    }

    1;



See Test2::API::Context for documentation on what the $ctx object can do.

SOURCE

The source code repository for Test2-Suite can be found at http://github.com/Test-More/Test2-Suite/.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright 2015 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TEST2::TOOLS (3) 2016-03-20

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.