Debian Codegraph @

upstream/debian-unstable/man3/Test2::Manual::Testing::Todo.3perl

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