Debian Codegraph @

upstream/mageia-cauldron/man3pm/Test2::Manual::Testing::Todo.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::Manual::Testing::Todo 3pm"
61 .TH Test2::Manual::Testing::Todo 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::Manual::Testing::Todo \- Tutorial for marking tests as TODO.
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 This tutorial covers the process of marking tests as TODO. It also describes
71 how TODO works under the hood.
72 .SH "THE TOOL"
73 .IX Header "THE TOOL"
74 .Vb 1
75 \& use Test2::Tools::Basic qw/todo/;
76 .Ve
77 .SS "TODO BLOCK"
78 .IX Subsection "TODO BLOCK"
79 This form is low\-magic. All tests inside the block are marked as todo, tests
80 outside the block are not todo. You do not need to do any variable management.
81 The flaw with this form is that it adds a couple levels to the stack, which can
82 break some high\-magic tests.
83 .PP
84 Overall this is the preferred form unless you have a special case that requires
85 the variable form.
86 .PP
87 .Vb 4
88 \& todo "Reason for the todo" => sub {
89 \& ok(0, "fail but todo");
90 \& ...
91 \& };
92 .Ve
93 .SS "TODO VARIABLE"
94 .IX Subsection "TODO VARIABLE"
95 This form maintains the todo scope for the life of the variable. This is useful
96 for tests that are sensitive to scope changes. This closely emulates the
97 Test::More style which localized the \f(CW$TODO\fR package variable. Once the
98 variable is destroyed (set it to undef, scope end, etc) the TODO state ends.
99 .PP
100 .Vb 4
101 \& my $todo = todo "Reason for the todo";
102 \& ok(0, "fail but todo");
103 \& ...
104 \& $todo = undef;
105 .Ve
106 .SH "MANUAL TODO EVENTS"
107 .IX Header "MANUAL TODO EVENTS"
108 .Vb 1
109 \& use Test2::API qw/context/;
110 \&
111 \& sub todo_ok {
112 \& my ($bool, $name, $todo) = @_;
113 \&
114 \& my $ctx = context();
115 \& $ctx\->send_event(\*(AqOk\*(Aq, pass => $bool, effective_pass => 1, todo => $todo);
116 \& $ctx\->release;
117 \&
118 \& return $bool;
119 \& }
120 .Ve
121 .PP
122 The Test2::Event::Ok event has a \f(CW\*(C`todo\*(C'\fR field which should have the todo
123 reason. The event also has the \f(CW\*(C`pass\*(C'\fR and \f(CW\*(C`effective_pass\*(C'\fR fields. The
124 \&\f(CW\*(C`pass\*(C'\fR field is the actual pass/fail value. The \f(CW\*(C`effective_pass\*(C'\fR is used to
125 determine if the event is an actual failure (should always be set tot true with
126 todo).
127 .SH "HOW THE TODO TOOLS WORK UNDER THE HOOD"
128 .IX Header "HOW THE TODO TOOLS WORK UNDER THE HOOD"
129 The Test2::Todo library gets the current Test2::Hub instance and adds a
130 filter. The filter that is added will set the \f(CW\*(C`todo\*(C'\fR and \f(CW\*(C`effective_pass\*(C'\fR fields on
131 any Test2::Event::Ok events that pass through the hub. The filter also
132 converts Test2::Event::Diag events into Test2::Event::Note events.
133 .SH "SEE ALSO"
134 .IX Header "SEE ALSO"
135 Test2::Manual \- Primary index of the manual.
136 .SH SOURCE
137 .IX Header "SOURCE"
138 The source code repository for Test2\-Manual can be found at
139 \&\fIhttps://github.com/Test\-More/test\-more/\fR.
140 .SH MAINTAINERS
141 .IX Header "MAINTAINERS"
142 .IP "Chad Granum <[email protected]>" 4
143 .IX Item "Chad Granum <[email protected]>"
144 .SH AUTHORS
145 .IX Header "AUTHORS"
146 .IP "Chad Granum <[email protected]>" 4
147 .IX Item "Chad Granum <[email protected]>"
148 .SH COPYRIGHT
149 .IX Header "COPYRIGHT"
150 Copyright Chad Granum <[email protected]>.
151 .PP
152 This program is free software; you can redistribute it and/or
153 modify it under the same terms as Perl itself.
154 .PP
155 See \fIhttp://dev.perl.org/licenses/\fR