1Test::Stream::Plugin::SUusbetresCto(n3t)ributed Perl DocTuemsetn:t:aSttiroenam::Plugin::Subtest(3)
2
3
4

NAME

6       Test::Stream::Plugin::Subtest - Tools for writing subtests
7

DESCRIPTION

9       This package exports subs that let you write subtests.
10
11       There are 2 types of subtests, buffered and streamed. Streamed subtests
12       mimick subtest from Test::More in that they render all events as soon
13       as they are produced. Buffered subtests wait until the subtest
14       completes before rendering any results.
15
16       The main difference is that streamed subtests are unreadable when
17       combined with concurrency. Buffered subtests look fine with any number
18       of concurrent threads and processes.
19

DEPRECATED

21       This distribution is deprecated in favor of Test2, Test2::Suite, and
22       Test2::Workflow.
23
24       See Test::Stream::Manual::ToTest2 for a conversion guide.
25

SYNOPSIS

27           use Test::Stream qw/Subtest/;
28
29           subtest foo => sub {
30               ...
31           };
32
33   STREAMED
34       The default option is 'buffered', use this if you want streamed, the
35       way Test::Builder does it.
36
37           # You can use either of the next 2 lines, they are both equivilent
38           use Test::Stream Subtest => ['streamed'];
39           use Test::Stream::Plugin::Subtest qw/streamed/;
40
41           subtest my_test => sub {
42               ok(1, "subtest event A");
43               ok(1, "subtest event B");
44           };
45
46       This will produce output like this:
47
48           # Subtest: my_test
49               ok 1 - subtest event A
50               ok 2 - subtest event B
51               1..2
52           ok 1 - Subtest: my_test
53
54   BUFFERED
55           # You can use either of the next 2 lines, they are both equivilent
56           use Test::Stream Subtest => ['buffered'];
57           use Test::Stream::Plugin::Subtest qw/buffered/;
58
59           subtest my_test => sub {
60               ok(1, "subtest event A");
61               ok(1, "subtest event B");
62           };
63
64       This will produce output like this:
65
66           ok 1 - my_test {
67               ok 1 - subtest event A
68               ok 2 - subtest event B
69               1..2
70           }
71
72   BOTH
73           use Test::Stream::Plugin::Subtest qw/subtest_streamed subtest_buffered/;
74
75           subtest_streamed my_streamed_test => sub {
76               ok(1, "subtest event A");
77               ok(1, "subtest event B");
78           };
79
80           subtest_buffered my_buffered_test => sub {
81               ok(1, "subtest event A");
82               ok(1, "subtest event B");
83           };
84
85       This will produce the following output:
86
87           # Subtest: my_test
88               ok 1 - subtest event A
89               ok 2 - subtest event B
90               1..2
91           ok 1 - Subtest: my_test
92
93           ok 2 - my_test {
94               ok 1 - subtest event A
95               ok 2 - subtest event B
96               1..2
97           }
98

IMPORTANT NOTE

100       You can use "bail_out" or "skip_all" in a subtest, but not in a BEGIN
101       block or use statement. This is due to the way flow control works
102       within a begin block. This is not normally an issue, but can happen in
103       rare conditions using eval, or script files as subtests.
104

EXPORTS

106       subtest_streamed $name => $sub
107       subtest_streamed($name, $sub, @args)
108           Run subtest coderef, stream events as they happen.
109
110       subtest_buffered $name => $sub
111       subtest_buffered($name, $sub, @args)
112           Run subtest coderef, render events all at once when subtest is
113           complete.
114

SOURCE

116       The source code repository for Test::Stream can be found at
117       http://github.com/Test-More/Test-Stream/.
118

MAINTAINERS

120       Chad Granum <exodist@cpan.org>
121

AUTHORS

123       Chad Granum <exodist@cpan.org>
124
126       Copyright 2015 Chad Granum <exodist7@gmail.com>.
127
128       This program is free software; you can redistribute it and/or modify it
129       under the same terms as Perl itself.
130
131       See http://dev.perl.org/licenses/
132
133
134
135perl v5.34.0                      2022-01-21  Test::Stream::Plugin::Subtest(3)
Impressum