Test::S...:Subtest(3)

πŸ“¦
version 1.302027 Β· 2 versions
, in fedora 43

πŸ’– 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::More in 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 => $sub
  • subtest_streamed($name, $sub, @args)

Run subtest coderef, stream events as they happen. πŸ”₯

  • subtest_buffered $name => $sub
  • subtest_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 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