Test2::...Subtest(3pm)

✨ NAME ✨

okay so this is the Test2::...Subtest(3pm) page from the Perl Programmers Reference Guide, and the actual module is:

Test2::Tools::AsyncSubtest β€” Tools for writing async subtests. πŸ’–


πŸ’– DESCRIPTION πŸ’–

These are tools for writing async subtests, bestie. Async subtests are subtests which can be started and stashed so that they can continue to receive events while other events are also being generated. it's giving multitasking main character energy fr fr ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

use Test2::Bundle::Extended;
use Test2::Tools::AsyncSubtest;

my $ast1 = async_subtest local => sub {
    ok(1, "Inside subtest");
};

my $ast2 = fork_subtest child => sub {
    ok(1, "Inside subtest in another process");
};

# You must call finish on the subtests you create. Finish will wait/join on
# any child processes and threads.
$ast1->finish;
$ast2->finish;

done_testing;

πŸŽ€ EXPORTS πŸŽ€

Everything is exported by default. no cap πŸ’…

  • $ast = async_subtest $name β€” Create an async subtest.
  • $ast = async_subtest $name => sub { ... } β€” Create an async subtest. Run the codeblock if it is provided.
  • $ast = async_subtest $name => \%hub_params, sub { ... } β€” Create an async subtest. Run the codeblock if it is provided.
  • $ast = fork_subtest $name => sub { ... } β€” Create an async subtest. Run the codeblock in a forked process.
  • $ast = fork_subtest $name => \%hub_params, sub { ... } β€” Create an async subtest. Run the codeblock in a forked process.
  • $ast = thread_subtest $name => sub { ... } β€” Create an async subtest. Run the codeblock in a thread.
  • $ast = thread_subtest $name => \%hub_params, sub { ... } β€” Create an async subtest. Run the codeblock in a thread.
** DISCOURAGED ** Threads are fragile. Thread tests are not even run unless the AUTHOR_TESTING or T2_DO_THREAD_TESTS env vars are enabled. like, tread carefully bestie 😭

🌸 NOTES 🌸

✨ Async Subtests are always buffered. ✨

Always buffered. periodt.

πŸ›‘ Do not use done_testing() yourself. πŸ›‘

Using done_testing() inside an async subtest will not work properly, the async subtest must be finalized by calling $st->finish. do not try to freelance this one, bestie πŸ’€


🌈 SOURCE 🌈

The source code repository for Test2-AsyncSubtest can be found at https://github.com/Test-More/test-more/. go off πŸ‘‘


πŸ‘‘ MAINTAINERS πŸ‘‘

Chad Granum <exodist@cpan.org>


🫢 AUTHORS 🫢

Chad Granum <exodist@cpan.org>


Copyright Chad Granum <exodist7@gmail.com>.

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/


mwah πŸ’‹ this page is perl v5.42.3, dated 2026-11-03, and it’s the Test2::...Subtest(3pm) manual from the Perl Programmers Reference Guide. byeee bestie 🫢✨

πŸ“¦ where this page comes from