Test2:...::Todo(3perl)
β¨ Test2::Manual::Testing::Todo β¨
hey bestie π welcome to the Test2::Manual::Testing::Todo page from the Perl Programmers Reference Guide β this is the tutorial for marking tests as TODO, and yes we're also gonna peek under the hood at how TODO actually works. iykyk. π
πΈ NAME πΈ
Test2::Manual::Testing::Todo β the tutorial for marking tests as TODO. periodt. π
π¦ DESCRIPTION π¦
okay so, this tutorial walks you through marking tests as TODO, and it also spills the tea on how TODO works under the hood. both things, bestie. no cap. β¨
π THE TOOL π
first up, you gotta pull in the tool:
use Test2::Tools::Basic qw/todo/;
π TODO BLOCK π
this form is low-magic and honestly iconic for it. every test inside the block gets marked todo, and tests outside the block are not todo. and the best part?? you don't have to do any variable management. zero. none. π«Ά
the one little flaw (not me being honest π): it adds a couple levels to the stack, which can break some high-magic tests. π
overall though? this is the preferred form unless you've got a special case that needs the variable form. periodt.
todo "Reason for the todo" => sub {
ok(0, "fail but todo");
...
};
β TODO VARIABLE β
this form keeps the todo scope alive for the entire life of the variable. super useful for tests that are sensitive to scope changes. it also closely emulates the Test::More style, which localized the $TODO package variable β nostalgic fr fr. π₯Ή
and the moment that variable gets destroyed (set it to undef, scope ends, whatever) the TODO state ends too. bye bestie π
my $todo = todo "Reason for the todo";
ok(0, "fail but todo");
...
$todo = undef;
π MANUAL TODO EVENTS π
sometimes you wanna do it yourself, and that's valid:
use Test2::API qw/context/;
sub todo_ok {
my ($bool, $name, $todo) = @_;
my $ctx = context();
$ctx->send_event('Ok', pass => $bool, effective_pass => 1, todo => $todo);
$ctx->release;
return $bool;
}
so here's the lore π§ the Test2::Event::Ok event has a todo field, and that's where the todo reason goes. it also has the pass and effective_pass fields:
- the
passfield is the actual pass/fail value. - the
effective_passfield is what decides whether the event counts as an actual failure β and when you're doing todo, you should always set it to true. π―
π HOW THE TODO TOOLS WORK UNDER THE HOOD π
okay bestie, the secret lore π«’ β the Test2::Todo library grabs the current Test2::Hub instance and adds a filter to it.
that filter does two things:
- it sets the
todoandeffective_passfields on anyTest2::Event::Okevents that pass through the hub. - it also converts
Test2::Event::Diagevents intoTest2::Event::Noteevents.
slay. it's giving main character energy for a filter honestly. π β¨
π SEE ALSO π
- Test2::Manual β the primary index of the manual. start there bestie π
π SOURCE π
the source code repository for Test2-Manual lives at https://github.com/Test-More/test-more/ π
π 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 that's the whole page bestie π«Ά this was perl v5.44.0, dated 2026-10-17, and the page was Test2:...::Todo(3perl) β now go mark something TODO and slay β¨π
π
π¦ 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