in reply to debug output from TODO with Test::More

Hi 1nickt,

As far as I can tell from the Test::Builder doc, the output of diag is directed to a special handle during TODO tests. Apparently I can force that output to be displayed with Test::More->builder->todo_output(\*STDERR);. However, I don't find that very elegant since it does this unconditionally. (Update: Probably better: Test::More->builder->todo_output(Test::More->builder->failure_output);)

I played around with it a bit, here's a possibility to display a list of unexpectedly passing TODO tests without having to add a diag statement to every one of them. Stick this at the bottom of your test script (Perl v5.12 required for each @ARRAY):

my @details = Test::More->builder->details; while (my ($i,$t) = each @details) { next unless $$t{type} eq 'todo' && $$t{actual_ok}; diag "Passing TODO Test #".($i+1)." / $$t{name}"; }

(As you probably already know, there's also the "TODO passed" output that's already part of the "Test Summary Report". As far as I can tell from a look at the source, that's generated by TAP::Formatter::Base based on TAP::Parser's todo_passed.)

Hope this helps,
-- Hauke D

Replies are listed 'Best First'.
Re^2: debug output from TODO with Test::More
by Anonymous Monk on Jan 13, 2017 at 18:29 UTC
    Why do code all those lines when you can use SKIP? The reason can say "TODO" :-)

      Hi Anonymous,

      Why do code all those lines when you can use SKIP?

      Well first of all, because I was answering 1nickt's question, which is about TODO tests :-P

      Second, SKIP is not the same as TODO. SKIP doesn't run the test at all, whereas TODO runs it, but expects a failure, and reports when the test starts passing. If you use SKIP instead of TODO, you won't automatically get the information about tests that start passing.

      Regards,
      -- Hauke D

        "If you use SKIP instead of TODO, you won't automatically get the information about tests that start passing."

        And there is ZERO value in that. :-) It is not about the tests passing or failing -- it is about why you are or are not running the tests. TODO is pointless, SKIP has the real value.