Test2::...lanning(3pm)
π NAME π
Test2::Manual::Testing::Planning β literally all the ways you can set a plan, bestie. Every single one. This is the Test2::...lanning(3pm) page from the Perl Programmers Reference Guide, and we're gonna get through it together π«Ά
β¨ DESCRIPTION β¨
Okay so this tutorial is your one-stop glow-up for setting a plan. There are many ways, and we're covering all of them, no cap. Let's go π
π’ TEST COUNT π’
The plan() function is given to you by Test2::Tools::Basic. It's the "I know exactly how many tests I'm running" vibe check π
You hand it an exact number of tests to run.
When can you call it? At the start of testing, or at the end. What you absolutely cannot do is call it partway through testing β that's a no π
use Test2::Tools::Basic;
plan(10); # 10 tests expected
...
π DONE TESTING π
The done_testing() function also comes from Test2::Tools::Basic. This one is the icon of β¨automaticβ¨ β it sets the plan to however many tests you actually ran. Main character energy, honestly.
Heads up bestie: this must be used at the very end of testing β
use Test2::Tools::Basic;
...
done_testing();
π SKIP ALL π
The skip_all() function, once again from Test2::Tools::Basic, does exactly what it says on the tin: it sets the plan to 0 and exits the test immediately. Not me setting the plan to zero and dipping π
You may also provide a skip reason that explains why the test should be skipped β highly recommend, it's giving communication πΈ
use Test2::Tools::Basic;
skip_all("This test will not run here") if ...;
...
π§ CUSTOM PLAN EVENT π§
Plot twist: a plan is just, like, an Test2::Event::Plan event that gets sent to the current hub. That's it. That's the whole thing. So you could always write your own tool to set the plan β DIY queen behaviour π
use Test2::API qw/context/;
sub set_plan {
my $count = @_;
my $ctx = context();
$ctx->send_event('Plan', max => $count);
$ctx->release;
return $count;
}
π SEE ALSO π
Test2::Manualβ the primary index of the manual, aka your home base π‘
π¦ SOURCE π¦
The source code repository for Test2-Manual can be found at https://github.com/Test-More/test-more/ β go star it, it's iconic β
π«Ά MAINTAINERS π«Ά
- Chad Granum
<exodist@cpan.org>
π AUTHORS π
- Chad Granum
<exodist@cpan.org>
π COPYRIGHT π
Copyright Chad Granum <exodist@cpan.org>.
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/
and that's the whole page bestie, ily, go set some plans πβ¨ this was perl v5.42.3, dated 2026-11-03, signing off from Test2::...lanning(3pm) β mwah π
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms