1Test2::Manual::Testing:U:sTeordoC(o3n)tributed Perl DocuTmeesntt2a:t:iMoannual::Testing::Todo(3)
2
3
4

NAME

6       Test2::Manual::Testing::Todo - Tutorial for marking tests as TODO.
7

DESCRIPTION

9       This tutorial covers the process of marking tests as TODO. It also
10       describes how TODO works under the hood.
11

THE TOOL

13           use Test2::Tools::Basic qw/todo/;
14
15   TODO BLOCK
16       This form is low-magic. All tests inside the block are marked as todo,
17       tests outside the block are not todo. You do not need to do any
18       variable management.  The flaw with this form is that it adds a couple
19       levels to the stack, which can break some high-magic tests.
20
21       Overall this is the preferred form unless you have a special case that
22       requires the variable form.
23
24           todo "Reason for the todo" => sub {
25               ok(0, "fail but todo");
26               ...
27           };
28
29   TODO VARIABLE
30       This form maintains the todo scope for the life of the variable. This
31       is useful for tests that are sensitive to scope changes. This closely
32       emulates the Test::More style which localized the $TODO package
33       variable. Once the variable is destroyed (set it to undef, scope end,
34       etc) the TODO state ends.
35
36           my $todo = todo "Reason for the todo";
37           ok(0, "fail but todo");
38           ...
39           $todo = undef;
40

MANUAL TODO EVENTS

42           use Test2::API qw/context/;
43
44           sub todo_ok {
45               my ($bool, $name, $todo) = @_;
46
47               my $ctx = context();
48               $ctx->send_event('Ok', pass => $bool, effective_pass => 1, todo => $todo);
49               $ctx->release;
50
51               return $bool;
52           }
53
54       The Test2::Event::Ok event has a "todo" field which should have the
55       todo reason. The event also has the "pass" and "effective_pass" fields.
56       The "pass" field is the actual pass/fail value. The "effective_pass" is
57       used to determine if the event is an actual failure (should always be
58       set tot true with todo).
59

HOW THE TODO TOOLS WORK UNDER THE HOOD

61       The Test2::Todo library gets the current Test2::Hub instance and adds a
62       filter. The filter that is added will set the todo and effective pass
63       fields on any Test2::Event::Ok events that pass through the hub. The
64       filter also converts Test2::Event::Diag events into Test2::Event::Note
65       events.
66

SEE ALSO

68       Test2::Manual - Primary index of the manual.
69

SOURCE

71       The source code repository for Test2-Manual can be found at
72       https://github.com/Test-More/Test2-Suite/.
73

MAINTAINERS

75       Chad Granum <exodist@cpan.org>
76

AUTHORS

78       Chad Granum <exodist@cpan.org>
79
81       Copyright 2018 Chad Granum <exodist@cpan.org>.
82
83       This program is free software; you can redistribute it and/or modify it
84       under the same terms as Perl itself.
85
86       See http://dev.perl.org/licenses/
87
88
89
90perl v5.36.0                      2022-07-22   Test2::Manual::Testing::Todo(3)
Impressum