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