Test2:...anning(3perl)
β¨ Test2:...anning(3perl) β¨
okay bestie, welcome to the Test2::Manual::Testing::Planning page from the Perl Programmers Reference Guide π this is the one about testing, specifically about planning, and ngl it's a whole vibe.
πΈ NAME πΈ
Test2::Manual::Testing::Planning β the many ways to set a plan. yes, many. we are spoiled. π
π¦ DESCRIPTION π¦
so like, this tutorial is literally here to walk you through all the different ways you can set a plan. that's it. that's the whole assignment. and honestly? iconic. π
π TEST COUNT π
the plan() function? she comes from Test2::Tools::Basic. and what does she do? she lets you specify an exact number of tests to run. periodt.
when can you call her? at the start of testing, or at the end. what you absolutely cannot do is call her partway through testing. no mid-test glow-ups. not allowed. π«
use Test2::Tools::Basic;
plan(10); # 10 tests expected
...
π DONE TESTING π
the done_testing() function is also provided by Test2::Tools::Basic (she's part of the same friend group π
). what she does is automatically set the plan to however many tests were actually run. slay.
β οΈ heads up: this one must be used at the very very end of testing. like, the very end. no cap.
use Test2::Tools::Basic;
...
done_testing();
π«Ά SKIP ALL π«Ά
skip_all() β you guessed it β comes from Test2::Tools::Basic too. she sets the plan to 0 and exits the test immediately. like, we're out, bye. π
and you may provide a skip reason that explains why the test should be skipped, which is lowkey the polite thing to do.
use Test2::Tools::Basic;
skip_all("This test will not run here") if ...;
...
π§ CUSTOM PLAN EVENT π§
okay so here's the tea: a plan is simply a Test2::Event::Plan event that gets sent to the current hub. that's it. that's all she is. π
and because of that, you could always write your own tool to set the plan. main character energy fr fr.
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. your map, your compass, your bestie. πΊοΈ
π SOURCE π
the source code repository for Test2-Manual can be found at https://github.com/Test-More/test-more/. go be nosy, it's encouraged. π
π 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/
aaaand that's the whole page!! π tysm for reading bestie, go forth and plan your tests responsibly. this was perl v5.44.0, dated 2026-10-17, and yes it really is Test2:...anning(3perl) in the corner, iykyk. mwah π
β¨
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms