Debian Codegraph @

upstream/mageia-cauldron/man3pm/Test2::Tools::Subtest.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "Test2::Tools::Subtest 3pm"
61 .TH Test2::Tools::Subtest 3pm 2025-06-24 "perl v5.42.0" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 Test2::Tools::Subtest \- Tools for writing subtests
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 This package exports subs that let you write subtests.
71 .PP
72 There are two types of subtests, buffered and streamed. Streamed subtests mimic
73 subtests from Test::More in that they render all events as soon as they are
74 produced. Buffered subtests wait until the subtest completes before rendering
75 any results.
76 .PP
77 The main difference is that streamed subtests are unreadable when combined with
78 concurrency. Buffered subtests look fine with any number of concurrent threads
79 and processes.
80 .SH SYNOPSIS
81 .IX Header "SYNOPSIS"
82 .SS BUFFERED
83 .IX Subsection "BUFFERED"
84 .Vb 1
85 \& use Test2::Tools::Subtest qw/subtest_buffered/;
86 \&
87 \& subtest_buffered my_test => sub {
88 \& ok(1, "subtest event A");
89 \& ok(1, "subtest event B");
90 \& };
91 .Ve
92 .PP
93 This will produce output like this:
94 .PP
95 .Vb 5
96 \& ok 1 \- my_test {
97 \& ok 1 \- subtest event A
98 \& ok 2 \- subtest event B
99 \& 1..2
100 \& }
101 .Ve
102 .SS STREAMED
103 .IX Subsection "STREAMED"
104 The default option is \*(Aqbuffered\*(Aq. If you want streamed subtests,
105 the way Test::Builder does it, use this:
106 .PP
107 .Vb 1
108 \& use Test2::Tools::Subtest qw/subtest_streamed/;
109 \&
110 \& subtest_streamed my_test => sub {
111 \& ok(1, "subtest event A");
112 \& ok(1, "subtest event B");
113 \& };
114 .Ve
115 .PP
116 This will produce output like this:
117 .PP
118 .Vb 5
119 \& # Subtest: my_test
120 \& ok 1 \- subtest event A
121 \& ok 2 \- subtest event B
122 \& 1..2
123 \& ok 1 \- Subtest: my_test
124 .Ve
125 .SH "IMPORTANT NOTE"
126 .IX Header "IMPORTANT NOTE"
127 You can use \f(CW\*(C`bail_out\*(C'\fR or \f(CW\*(C`skip_all\*(C'\fR in a subtest, but not in a BEGIN block
128 or \f(CW\*(C`use\*(C'\fR statement. This is due to the way flow control works within a BEGIN
129 block. This is not normally an issue, but can happen in rare conditions using
130 eval, or script files as subtests.
131 .SH EXPORTS
132 .IX Header "EXPORTS"
133 .ie n .IP "subtest_streamed $name => $sub" 4
134 .el .IP "subtest_streamed \f(CW$name\fR => \f(CW$sub\fR" 4
135 .IX Item "subtest_streamed $name => $sub"
136 .PD 0
137 .ie n .IP "subtest_streamed($name, $sub, @args)" 4
138 .el .IP "subtest_streamed($name, \f(CW$sub\fR, \f(CW@args\fR)" 4
139 .IX Item "subtest_streamed($name, $sub, @args)"
140 .ie n .IP "subtest_streamed $name => \e%params, $sub" 4
141 .el .IP "subtest_streamed \f(CW$name\fR => \e%params, \f(CW$sub\fR" 4
142 .IX Item "subtest_streamed $name => %params, $sub"
143 .ie n .IP "subtest_streamed($name, \e%params, $sub, @args)" 4
144 .el .IP "subtest_streamed($name, \e%params, \f(CW$sub\fR, \f(CW@args\fR)" 4
145 .IX Item "subtest_streamed($name, %params, $sub, @args)"
146 .PD
147 Run subtest coderef, stream events as they happen.
148 .Sp
149 \&\f(CW\*(C`\e%params\*(C'\fR is a hashref with any arguments you wish to pass into hub
150 construction.
151 .ie n .IP "subtest_buffered $name => $sub" 4
152 .el .IP "subtest_buffered \f(CW$name\fR => \f(CW$sub\fR" 4
153 .IX Item "subtest_buffered $name => $sub"
154 .PD 0
155 .ie n .IP "subtest_buffered($name, $sub, @args)" 4
156 .el .IP "subtest_buffered($name, \f(CW$sub\fR, \f(CW@args\fR)" 4
157 .IX Item "subtest_buffered($name, $sub, @args)"
158 .ie n .IP "subtest_buffered $name => \e%params, $sub" 4
159 .el .IP "subtest_buffered \f(CW$name\fR => \e%params, \f(CW$sub\fR" 4
160 .IX Item "subtest_buffered $name => %params, $sub"
161 .ie n .IP "subtest_buffered($name, \e%params, $sub, @args)" 4
162 .el .IP "subtest_buffered($name, \e%params, \f(CW$sub\fR, \f(CW@args\fR)" 4
163 .IX Item "subtest_buffered($name, %params, $sub, @args)"
164 .PD
165 Run subtest coderef, render events all at once when subtest is complete.
166 .Sp
167 \&\f(CW\*(C`\e%params\*(C'\fR is a hashref with any arguments you wish to pass into hub
168 construction.
169 .SH SOURCE
170 .IX Header "SOURCE"
171 The source code repository for Test2\-Suite can be found at
172 \&\fIhttps://github.com/Test\-More/test\-more/\fR.
173 .SH MAINTAINERS
174 .IX Header "MAINTAINERS"
175 .IP "Chad Granum <[email protected]>" 4
176 .IX Item "Chad Granum <[email protected]>"
177 .SH AUTHORS
178 .IX Header "AUTHORS"
179 .IP "Chad Granum <[email protected]>" 4
180 .IX Item "Chad Granum <[email protected]>"
181 .SH COPYRIGHT
182 .IX Header "COPYRIGHT"
183 Copyright Chad Granum <[email protected]>.
184 .PP
185 This program is free software; you can redistribute it and/or
186 modify it under the same terms as Perl itself.
187 .PP
188 See \fIhttp://dev.perl.org/licenses/\fR