GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test2::Manual::Testing::Todo(3) User Contributed Perl Documentation Test2::Manual::Testing::Todo(3)

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

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

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

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");
        ...
    };

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 Test::More 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;

    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 Test2::Event::Ok 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).

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

Test2::Manual - Primary index of the manual.

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

Chad Granum <exodist@cpan.org>

Chad Granum <exodist@cpan.org>

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/

2022-03-04 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.