1Test2::Todo(3)        User Contributed Perl Documentation       Test2::Todo(3)
2
3
4

NAME

6       Test2::Todo - TODO extension for Test2.
7

DESCRIPTION

9       This is an object that lets you create and manage TODO states for
10       tests. This is an extension, not a plugin or a tool. This library can
11       be used by plugins and tools to manage todo states.
12
13       If you simply want to write a todo test then you should look at the
14       "todo" function provided by Test2::Tools::Basic.
15

SYNOPSIS

17           use Test2::Todo;
18
19           # Start the todo
20           my $todo = Test2::Todo->new(reason => 'Fix later');
21
22           # Will be considered todo, so suite still passes
23           ok(0, "oops");
24
25           # End the todo
26           $todo->end;
27
28           # TODO has ended, this test will actually fail.
29           ok(0, "oops");
30

CONSTRUCTION OPTIONS

32       reason (required)
33           The reason for the todo, this can be any defined value.
34
35       hub (optional)
36           The hub to which the TODO state should be applied. If none is
37           provided then the current global hub is used.
38

INSTANCE METHODS

40       $todo->end
41           End the todo state.
42

CLASS METHODS

44       $count = Test2::Todo->hub_in_todo($hub)
45           If the hub has any todo objects this will return the total number
46           of them. If the hub has no todo objects it will return 0.
47

OTHER NOTES

49   How it works
50       When an instance is created a filter sub is added to the Test2::Hub.
51       This filter will set the "todo" and "diag_todo" attributes on all
52       events as they come in. When the instance is destroyed, or end() is
53       called, the filter is removed.
54
55       When a new hub is pushed (such as when a subtest is started) the new
56       hub will inherit the filter, but it will only set "diag_todo", it will
57       not set "todo" on events in child hubs.
58
59   $todo->end is called at destruction
60       If your $todo object falls out of scope and gets garbage collected, the
61       todo will end.
62
63   Can I use multiple instances?
64       Yes. The most recently created one that is still active will win.
65

SOURCE

67       The source code repository for Test2-Suite can be found at
68       https://github.com/Test-More/Test2-Suite/.
69

MAINTAINERS

71       Chad Granum <exodist@cpan.org>
72

AUTHORS

74       Chad Granum <exodist@cpan.org>
75
77       Copyright 2018 Chad Granum <exodist@cpan.org>.
78
79       This program is free software; you can redistribute it and/or modify it
80       under the same terms as Perl itself.
81
82       See http://dev.perl.org/licenses/
83
84
85
86perl v5.38.0                      2023-07-21                    Test2::Todo(3)
Impressum