Test2::Todo(3pm) Perl Programmers Reference Guide Test2::Todo(3pm)

# [NAME](#NAME)

Test2::Todo - TODO extension for Test2.

# [DESCRIPTION](#DESCRIPTION)

This is an object that lets you create and manage TODO states for tests. This is an extension, not a plugin or a tool. This library can be used by plugins and tools to manage todo states.

If you simply want to write a todo test then you should look at the "todo" function provided by Test2::Tools::Basic.

# [SYNOPSIS](#SYNOPSIS)

```
    use Test2::Todo;
    # Start the todo
    my $todo = Test2::Todo->new(reason => 'Fix later');
    # Will be considered todo, so suite still passes
    ok(0, "oops");
    # End the todo
    $todo->end;
    # TODO has ended, this test will actually fail.
    ok(0, "oops");
```

# [CONSTRUCTION OPTIONS](#CONSTRUCTION_OPTIONS)

[reason (required)](#reason)

The reason for the todo, this can be any defined value.

[hub (optional)](#hub)

The hub to which the TODO state should be applied. If none is provided then the current global hub is used.

# [INSTANCE METHODS](#INSTANCE_METHODS)

$todo-&gt;end

End the todo state.

# [CLASS METHODS](#CLASS_METHODS)

$count = Test2::Todo-&gt;hub\_in\_todo($hub)

If the hub has any todo objects this will return the total number of them. If the hub has no todo objects it will return 0.

# [OTHER NOTES](#OTHER_NOTES)

## [How it works](#How_it_works)

When an instance is created a filter sub is added to the Test2::Hub. This filter will set the "todo" and "diag\_todo" attributes on all events as they come in. When the instance is destroyed, or end() is called, the filter is removed.

When a new hub is pushed (such as when a subtest is started) the new hub will inherit the filter, but it will only set "diag\_todo", it will not set "todo" on events in child hubs.

## [$todo-&gt;end is called at destruction](#$todo)

If your $todo object falls out of scope and gets garbage collected, the todo will end.

## [Can I use multiple instances?](#Can_I_use_multiple_instances?)

Yes. The most recently created one that is still active will win.

# [SOURCE](#SOURCE)

The source code repository for Test2-Suite can be found at *https://github.com/Test-More/test-more/*.

# [MAINTAINERS](#MAINTAINERS)

[Chad Granum &lt;exodist@cpan.org&gt;](#Chad)

# [AUTHORS](#AUTHORS)

[Chad Granum &lt;exodist@cpan.org&gt;](#Chad~2)

# [COPYRIGHT](#COPYRIGHT)

Copyright Chad Granum &lt;exodist@cpan.org&gt;.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See *http://dev.perl.org/licenses/*

2026-10-21 perl v5.44.0

---

Document: Test2::Todo(3pm) from perl 5.44.0-r2 (Chainguard OS)
Source: https://github.com/Perl/perl5.git
