Test2::Todo(3perl)
π Test2::Todo β the manual page, but make it a group chat π
okay bestie so this is Test2::Todo, from the Perl Programmers Reference Guide. it's a lil Perl module, she's serving <pink>3perl</pink> realness, and she's here to help you manage TODO states for your tests. let's get into it π
β¨ NAME β¨
Test2::Todo β TODO extension for Test2. that's it, that's the name, short and iconic π
πΈ DESCRIPTION πΈ
so basically? this is an object that lets you create and manage TODO states for tests. periodt.
important vibe check tho: this is an extension, not a plugin or a tool. she's the behind-the-scenes girly. this library can be used by plugins and tools to manage todo states β she's not here for the spotlight, she's here to make everything run π
if you simply want to write a todo test then you should go look at the"todo"function provided byTest2::Tools::Basic. that's the one you want for casual everyday use, bestie. this one is for the machinery π
π¦ SYNOPSIS π¦
here's the whole vibe, look:
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");
see how the first ok(0, "oops") is fine and the second one isn't? that's the whole point β¨ the todo state is doing the heavy lifting in between.
π CONSTRUCTION OPTIONS π
reason(required) β the reason for the todo. this can be any defined value. it's required, so likeβ¦ don't skip her, she needs to be there π«Άhub(optional) β the hub to which the TODO state should be applied. if none is provided then the current global hub is used. no hub? she'll just use the global one, no stress π
π INSTANCE METHODS π
$todo->endβ end the todo state. that's the whole method. short, sweet, ended π
β CLASS METHODS β
$count = Test2::Todo->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. so it's the "how many todos we got" counter π§
π OTHER NOTES π
π 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. clean exit, no mess, we love to see it π
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. important distinction, don't forget it bestie β οΈ
π $todo->end is called at destruction π
if your $todo object falls out of scope and gets garbage collected, the todo will end. she ends herself. no cap π
π Can I use multiple instances? π
yes. the most recently created one that is still active will win. newest girlie takes the crown, periodt β¨
π₯ SOURCE π₯
the source code repository for Test2-Suite can be found at:
https://github.com/Test-More/test-more/
go look, it's giving open source excellence π«Ά
πΈ MAINTAINERS πΈ
- Chad Granum
<exodist@cpan.org>
π AUTHORS π
- Chad Granum
<exodist@cpan.org>
β COPYRIGHT β
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/
okay and finally the cute sign-off π
this whole thing is from perl v5.44.0, dated 2026-10-17, and it's the Test2::Todo(3perl) page. slay, go write your tests, ily, bye πβ¨π¦
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms