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 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