Test2::...Subtest(3)
okay bestie, this is the User Contributed Perl Documentation entry for Test2::...Subtest(3) β aka the page for Test2::Tools::AsyncSubtest, and itβs literally giving βasync subtests but make it fashion.β π
β¨
πΈ NAME πΈ
The main character is Test2::Tools::AsyncSubtest β tools for writing async subtests. Thatβs the whole gig, no cap. π«Ά
π¦ DESCRIPTION π¦
These are tools for writing async subtests. Async subtests are subtests that can be started and stashed so they can keep receiving events while other events are also being generated. Like, theyβre off doing their own thing but still showing up to the group chat. π
β¨ 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. Yes, everything β no import gymnastics required. π
async_subtestπ§$ast = async_subtest $name$ast = async_subtest $name => sub { ... }$ast = async_subtest $name => \%hub_params, sub { ... }- Create an async subtest. Run the codeblock if it is provided.
fork_subtestπ$ast = fork_subtest $name => sub { ... }$ast = fork_subtest $name => \%hub_params, sub { ... }- Create an async subtest. Run the codeblock in a forked process.
thread_subtestπ$ast = thread_subtest $name => sub { ... }$ast = thread_subtest $name => \%hub_params, sub { ... }- ** DISCOURAGED ** Threads are fragile. Thread tests are not even run unless the
AUTHOR_TESTINGorT2_DO_THREAD_TESTSenv vars are enabled. - Create an async subtest. Run the codeblock in a thread.
π NOTES π
- Async Subtests are always buffered.
- Always buffered. Like, thatβs the note. π«Ά
- 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. Periodt. π
- Using
π₯ SOURCE π₯
The source code repository for Test2-AsyncSubtest can be found at https://github.com/Test-More/test-more/. Go peek, bestie. π
π MAINTAINERS π
Chad Granum <exodist@cpan.org> β maintained with love. π«Ά
π AUTHORS π
Chad Granum <exodist@cpan.org> β author energy, iconic. β¨
π COPYRIGHT π
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 from perl v5.42.0, dated 2025-07-28, and itβs the Test2::...Subtest(3) manual β bye bestie, go write some async subtests! π¦β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Test-Simple 1.302214-bp160.1.2 Β· Artistic-1.0 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