Perl Diver 2.31
Main Environment Variables Perl Default Values Perl Config - Summary Perl Config - Full Installed Modules List Directory uptime Docs

Module Documentation
Details and documentation about a specific module, including version and documentation (if available). Note that while links to perldoc.com and search.cpan.org are provided, the module may be part of a larger distribution. If you reach a File Not Found page on either site, please try the parent module.

Test2::Manual::Testing::Todo

Name Test2::Manual::Testing::Todo
Version 0.000144
Located at /usr/local/share/perl5
File /usr/local/share/perl5/Test2/Manual/Testing/Todo.pm
Is Core No
Search CPAN for this module Test2::Manual::Testing::Todo
Documentation Test2::Manual::Testing::Todo
Module Details Test2::Manual::Testing::Todo

NAME

Test2::Manual::Testing::Todo - Tutorial for marking tests as TODO.


DESCRIPTION

This tutorial covers the process of marking tests as TODO. It also describes how TODO works under the hood.


THE TOOL

    use Test2::Tools::Basic qw/todo/;

TODO BLOCK

This form is low-magic. All tests inside the block are marked as todo, tests outside the block are not todo. You do not need to do any variable management. The flaw with this form is that it adds a couple levels to the stack, which can break some high-magic tests.

Overall this is the preferred form unless you have a special case that requires the variable form.

    todo "Reason for the todo" => sub {
        ok(0, "fail but todo");
        ...
    };

TODO VARIABLE

This form maintains the todo scope for the life of the variable. This is useful for tests that are sensitive to scope changes. This closely emulates the the Test::More manpage style which localized the $TODO package variable. Once the variable is destroyed (set it to undef, scope end, etc) the TODO state ends.

    my $todo = todo "Reason for the todo";
    ok(0, "fail but todo");
    ...
    $todo = undef;


MANUAL TODO EVENTS

    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;
    }

The the Test2::Event::Ok manpage event has a todo field which should have the todo reason. The event also has the pass and effective_pass fields. The pass field is the actual pass/fail value. The effective_pass is used to determine if the event is an actual failure (should always be set tot true with todo).


HOW THE TODO TOOLS WORK UNDER THE HOOD

The the Test2::Todo manpage library gets the current the Test2::Hub manpage instance and adds a filter. The filter that is added will set the todo and effective pass fields on any the Test2::Event::Ok manpage events that pass through the hub. The filter also converts the Test2::Event::Diag manpage events into the Test2::Event::Note manpage events.


SEE ALSO

the Test2::Manual manpage - Primary index of the manual.


SOURCE

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


MAINTAINERS

Chad Granum


AUTHORS

Chad Granum <exodist@cpan.org>Chad Granum


COPYRIGHT

Copyright 2018 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/

Perl Diver brought to you by ScriptSolutions.com © 1997- 2024