NAME

Test::Seperate - Seperate sets of tests from others to prevent bleeding between tests, or to restore EVERYTHING between tests.

DESCRIPTION

Test::Seperate allows you to run tests seperately. This is useful for returning to a known or pristine state between tests. Test::Seperate seperates tests into different forked processes. You can do whatever you want in a test set without fear that something you do will effect a test in another set.

SYNOPSYS

#!/usr/bin/perl
use strict;
use warnings;

use Test::More tests => 5;
use Test::Seperate;

# Counts as 2 tests, the ok() within, and seperate_tests() itself.
seperate_tests { ok( 1, "a test that has been seperated" ) } "A seperate test";

# Define a new package w/ a package variable inside a seperate test
seperate_tests {
    {
        package Test::Seperate::__Test;
        our $TEST = 1;
    }

    is( $Test::Seperate::__Test::TEST, 1, "Found package variable defined in seperate test while in seperate test scope" );
} "Package defined in seperate test";

# Package from seperate test does not bleed out.
ok(
    !defined( $Test::Seperate::__Test::TEST ),
    "Package variable defined in seperate test no longer defined outside of seperate test"
);

HOW IT WORKS

Test::Seperate will fork a new process when you run seperate_tests(). Before forking a pipe will be opened through which the processes may communicate. Within the child process all Test::More subs will be overriden to store their parameters instead of running their checks. When the child is finished it sends the information to the parent via the open pipe. The parent will run the appropreat tests using the values provided from the child.

EXPORTED FUNCTIONS

seperate_tests( sub { ok( 1, 'test' ); ... }, $message )

Runs the sub in a forked process. Overrides any Test::More subs so that they will be run in the parent when the child exists.

Note: When a test fails it will say the failure occured in Test/Seperate.pm, however a seperate diagnostics message will be printed with the correct filename and line number.

SEE ALSO

Test::Fork Test::MultiFork Test::SharedFork

AUTHORS

Chad Granum exodist7@gmail.com

COPYRIGHT

Copyright (C) 2009 Chad Granum

Test-Seperate is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Test-Seperate 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 GNU General Public License for more details.