in reply to Using Data::Dumper in Test-Driven Development
At the risk of being pedantic, I thought I'd flesh out some information here.
As guha pointed out, using &diag instead of print is the way to go. &diag prints its messages in such a way so as to play nicely with Test::Harness. It's always possible that simply printing data could result in something that confuses Test::Harness and thus causes unpredictable results which could be hard to diagnose.
Also, it looks like you're using the venerable Test module instead of Test::More. In the former, your code makes perfect sense. In the latter you'll find that &ok does a simple boolean check, but &is makes the comparison, allows a test name to be assigned and gives very useful diagnostic info.
$ perl -MTest::More=tests,1 -e 'is(23,42,"Discordia should have the an +swer")' 1..1 not ok 1 - Discordia should have the answer # Failed test (-e at line 1) # got: '23' # expected: '42' # Looks like you failed 1 tests of 1.
And if you like the new Data::Dumper::Simple, you may wish to note that unlike Data::Dumper, the parentheses are required. That's lamentable, but it made it much easier to implement.
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using Data::Dumper in Test-Driven Development
by pbeckingham (Parson) on Aug 06, 2004 at 00:32 UTC |