NAME

TB2::OnlyOnePlan - Enforces there being only one plan per test

SYNOPSIS

# Add an instance of this to the TestState to enforce plans
use TB2::OnlyOnePlan;
$test_state->add_early_handlers( TB2::OnlyOnePlan->new );

DESCRIPTION

This is a TB2::EventHandler which enforces there being only one plan issued per test.

There are exceptions...

subtests have their own plan

Subtests must have their own plan, so that is allowed.

Multiple "no_plan"s are allowed

There's no harm in setting "no_plan" multiple times. This specifically allows...

use Test::More "no_plan";

...test test test...

done_testing();

Setting a fixed plan is allowed after a "no_plan"

There is no harm in raising the specificity of the plan. This specifically allows...

use Test::More "no_plan";

...test test test...

done_testing(5);

Setting a fixed plan the same as the existing fixed plan.

This specificially allows redundant planning...

use Test::More tests => 3;

pass("One");
pass("Two");
pass("Three");

done_testing(3);