Test2::Todo(3)

πŸ“¦ version 1.302214, in opensuse-leap 16.0

🌸 NAME 🌸

Test2::Todo β€” TODO extension for Test2. (Yes bestie, this is the manual page for Test2::Todo(3), and it's lowkey iconic.)

πŸ’– DESCRIPTION πŸ’–

Okay so this is an object that lets you create and manage TODO states for tests. It's an extension, not a plugin and not a tool. Plugins and tools can use this library 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. That's the one you want for the simple vibe.

✨ 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 πŸ› οΈ

  • reason (required) β€” the reason for the todo, and it can be any defined value.
  • hub (optional) β€” the hub to which the TODO state should be applied. If none is provided, then the current global hub is used.

πŸ’… INSTANCE METHODS πŸ’…

  • $todo->end β€” ends the todo state. That's it, that's the method.

πŸ‘‘ CLASS METHODS πŸ‘‘

  • $count = Test2::Todo->hub_in_todo($hub) β€” if the hub has any todo objects, this returns the total number of them. If the hub has no todo objects, it returns 0.

πŸ¦‹ OTHER NOTES πŸ¦‹

🧚 How it works

When an instance is created, a filter sub is added to the Test2::Hub. This filter sets 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->end is called at destruction πŸ’€

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

🌈 Can I use multiple instances? 🌈

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

πŸ”₯ SOURCE πŸ”₯

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

🫢 MAINTAINERS 🫢

Chad Granum <exodist@cpan.org>

⭐ AUTHORS ⭐

Chad Granum <exodist@cpan.org>

Copyright Chad Granum <exodist@cpan.org>.

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/


πŸ’– That’s the whole page, bestie β€” sourced from perl v5.42.0, dated 2025-07-28, for Test2::Todo(3). Later! πŸ’–

πŸ“¦ where this page comes from