On Saturday 29 March 2008 12:51:34 Buddy Burden wrote:

> The first is that _during development_, I want to stop my tests on the
> first failure.

Get a better harness.

> The second sticking point is the concept of plans, and here is where I
> really want to understand the reasoning behind it.  My understanding
> is that a plan has one primary function: to insure that if a test
> script dies before all the tests are run, that is recognized as an
> error.  Now, in my own test scripts, I achieved this via a very simple
> methodology: all my scripts ended with a simple print statement: "ALL
> DONE".  I ran the script, and if I saw my ALL DONE at the end, the
> script was fine.  If I didn't, I obviously had a problem.  Very
> simple, very clean.  My implementation was a bit simplistic, perhaps,
> but no matter how much I've read about testing in Perl, I still can't
> see why the idea itself isn't sound.

Any solution which requires a human being to read and think about the output 
beyond "It's all okay!" or "Something fell!"* is not a long-term solution.  
In particular, you lose the separation between producing TAP and interpreting 
TAP, as well as the automation benefits of both.

> So I guess I'm looking for enlightenment.  I can't help but feel like
> there's something I'm missing.  If the only function of a test plan is
> to make sure all the tests are run, my method handles that, and it's
> simpler and requires less bookkeeping.

The other function of a test plan is to make sure that you aren't running 
*more* tests than you intended.  If you don't know why that's important, try 
patching File::Find sometime.  I have.

> Not criticizing, not claiming my method is better, just looking for
> any reasons why this wouldn't work.  And, JIC there's some agreement
> that it _would_ work, I've already put together a patch for Test::Most
> that does it.  That is, at the top of your script, you put this:
>
>         use Test::Most 'defer_plan';
>
> and at the bottom of your script, you put this:
>
>         all_done();
>
> and it just DTRT.  The implementation is perhaps not as clean as I'd
> like it to be, but it's not a horrific hack either.  I'm going to
> forward it to Ovid through normal CPAN channels.
>
> Thoughts?

Suppose you take advantage of the existence of Test::Builder and roll in 
several other testing modules, per good programming practice of re-using 
working and well-tested code.  Whose responsibility is it then to emit the 
single canonical all_done() call?

I realize that this suggests that multiple test libraries should be able to 
add to the plan, and I'm sort of okay with that as well.

-- c

* I stopped reading Cerebus at Guys, partly because it was so difficult to 
find new phone books and partly because the second ascension ended so....

Reply via email to