On 28 Sep 2006, at 22:37, Jonathan Rockway wrote:
Override Test::Builder::ok to croak if it doesn't get a test name argument. Package that up in a module and shim it in with PERL5OPT or HARNESS_PERL_SWITCHES.

I kind of dislike this approach.  If my tests are failing, I want them
to fail because my program is broken, not because my tests are broken.

Me to - it's just that I interpret tests throwing exceptions as a failure of the test script, rather than a test failure. I try very hard no to have test scripts die.

I also don't want missing comments to stop my test from running...
sometimes you need to quickly fix something, run the tests, and *then*
make everything pretty.

Fair enough. Throw a warning instead, or log it.

If I had a big pile of tests without descriptions I wouldn't want them dying either.

However, if I had a test suite that had very few tests without descriptions then I would want things to die on a regular basis - since it should be trivial to clean up, and having it die in a nasty manner makes it more likely that I'd keep things clean.

YMMV of course :-)

So I would prefer that "t/style.t" fails due to "No description of test
on line 31 of frob.t", rather than t/frob.t failing (or croaking!) for
the same reason.

I'm not following the distinction you're drawing here... probably me being dim at this late hour :)

Unfortunately, this is sort of a only-perl-can-parse-Perl issue.  You
don't know that you didn't have a description until you've run the test.

The best thing I can think of is to have the harness check for comments,
and report an error at the end if some were missing.  Maybe it could
make up a test, so the output looks like:
[snip]
This has the added benefit of restricting this test to the developer -- it's unlikely that end-users of your module care about the TAP comments.
 I think this would be pretty easy to implement, too.

Yup. Log the errors by overriding Test::Builder::ok and have tap_comments check the log file.

Adrian

Reply via email to