Test::S...:Subtest(3)
π Test::S...:Subtest(3) β User Contributed Perl Documentation π
okay bestie so the manual name up top is literally Test::S...:Subtest(3) (yes it's abbreviated like that, that's just how it renders, don't come for me) and we're in the User Contributed Perl Documentation section. let's get into it π«Ά
β¨ NAME β¨
Test::Stream::Plugin::Subtest β tools for writing subtests. that's it, that's the whole name section, slay.
πΈ DESCRIPTION πΈ
So this package exports subs that let you write subtests. iconic behavior honestly.
There are 2 types of subtests, and you gotta know both:
- buffered β waits until the subtest completes before rendering any results. patient queen. π
- streamed β mimicks subtest from
Test::Morein that it renders all events as soon as they are produced. instant gratification energy.
The main difference (and this is the tea β): streamed subtests are unreadable when combined with concurrency. like, genuinely a mess. Buffered subtests look fine with any number of concurrent threads and processes. so if you're doing parallel stuff, buffered is the moment. β¨
π DEPRECATED π
ngl this whole distribution is deprecated in favor of Test2, Test2::Suite, and Test2::Workflow. it's giving "we've moved on bestie."
See Test::Stream::Manual::ToTest2 for a conversion guide. π¦
π SYNOPSIS π
use Test::Stream qw/Subtest/;
subtest foo => sub {
...
};
β STREAMED
The default option is 'buffered', use this if you want streamed, the way Test::Builder does it.
# You can use either of the next 2 lines, they are both equivilent
use Test::Stream Subtest => ['streamed'];
use Test::Stream::Plugin::Subtest qw/streamed/;
subtest my_test => sub {
ok(1, "subtest event A");
ok(1, "subtest event B");
};
This will produce output like this:
# Subtest: my_test
ok 1 - subtest event A
ok 2 - subtest event B
1..2
ok 1 - Subtest: my_test
π§ BUFFERED
# You can use either of the next 2 lines, they are both equivilent
use Test::Stream Subtest => ['buffered'];
use Test::Stream::Plugin::Subtest qw/buffered/;
subtest my_test => sub {
ok(1, "subtest event A");
ok(1, "subtest event B");
};
This will produce output like this:
ok 1 - my_test {
ok 1 - subtest event A
ok 2 - subtest event B
1..2
}
π BOTH
why choose when you can have both, main character energy:
use Test::Stream::Plugin::Subtest qw/subtest_streamed subtest_buffered/;
subtest_streamed my_streamed_test => sub {
ok(1, "subtest event A");
ok(1, "subtest event B");
};
subtest_buffered my_buffered_test => sub {
ok(1, "subtest event A");
ok(1, "subtest event B");
};
This will produce the following output:
# Subtest: my_test
ok 1 - subtest event A
ok 2 - subtest event B
1..2
ok 1 - Subtest: my_test
ok 2 - my_test {
ok 1 - subtest event A
ok 2 - subtest event B
1..2
}
β οΈ IMPORTANT NOTE β οΈ
You can use "bail_out" or "skip_all" in a subtest, but not in a BEGIN block or use statement. This is due to the way flow control works within a begin block. This is not normally an issue, but can happen in rare conditions using eval, or script files as subtests. so likeβ¦ watch out bestie π
π«Ά EXPORTS π«Ά
subtest_streamed $name => $subsubtest_streamed($name, $sub, @args)
Run subtest coderef, stream events as they happen. π₯
subtest_buffered $name => $subsubtest_buffered($name, $sub, @args)
Run subtest coderef, render events all at once when subtest is complete. β¨
πΈ SOURCE πΈ
The source code repository for Test::Stream can be found at http://github.com/Test-More/Test-Stream/.
π MAINTAINERS π
- Chad Granum
<exodist@cpan.org>
π AUTHORS π
- Chad Granum
<exodist@cpan.org>
π COPYRIGHT π
Copyright 2015 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/
okay that's the whole page, you ate that fr fr π
β¨ so anyway this was perl v5.42.0 dated 2025-07-25 β those are the version and date down at the bottom, and the manual name is Test::S...:Subtest(3), all of which we just covered. bye bestie, go write some subtests π¦π
π¦ where this page comes from
- fedora 43: perl-Test-Stream 1.302027-35.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms