I fold Log::Log4perl into our test code too - it allows me to on-the-fly enable messages about the state of the objects/structures concerned. Wrote some code that breaks a test case - just pump up the log level and watch the state of those object/structures change ...
#!/usr/bin/perl -w use strict; use Test::More qw(no_plan); use Data::Dumper; use Log::Log4perl qw(:levels); use HPA::LT_Utils::File; # the module under test Log::Log4perl->init_and_watch('generic_log.conf', 10); my $logger = get_logger('File'); my $file = HPA::LT_Utils::File->new(undef); is(scalar @{$file->[HPA::LT_Utils::File::_CP]}, 0) or $logger->debug(D +umper($file)); # check internal state is($file->output, '') or $logger->debug('the output() method seems to +have been borked - ', Dumper($file)); # check interface correctness ...

that example is effectively the same as just prints, the power is in log statements between test cases, when you sometimes want to see the state before some other group of ests run

# test requirement X is(....); is(....); is(....); $logger->debug('X OK, now test Y ', Dumper($obj)); # test requirement Y is(....); is(....); is(....);

The advantage is that you aren't constantly adding and deleting print statements - once the log statements are there, you enable/disable them as required.

use brain;


In reply to Re: Using Data::Dumper in Test-Driven Development by leriksen
in thread Using Data::Dumper in Test-Driven Development by dws

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.