Aristotle Pagaltzis wrote:
Note that it doesn’t quite protect you from running too few tests
either. You may botch some conditional in your test program and
end up skipping tests silently, in which case you will still
reach the `all_done()` line, and it’ll look as if all was fine.

The typical approach to setting the number of tests in anything but the most trivial cases is to run the tests and copy down the number. If the conditional wasn't working in the first place, then the plan does nothing but copy that mistake.

If your test is simple enough that you can routinely count the tests by hand, you're unlikely to miss running a test in the first place.


What it protects you from is dying half-way through the tests
without the harness noticing. Of course, that’s by far the most
common failure mode.

I don't want to drag out the "plan vs no_plan" argument, but I do want to clear up this common misconception.

Death is noted by both Test::More and Test::Harness and has been for a long time. Recent versions of Test::More close off a bug that caused death or non-zero exit codes to be lost in certain cases. If you continue to experience that, report it. It is a bug.

The only way you can abort the test halfway through using no_plan and get a success is with an exit(0). That scenario is extremely rare, but I've considered adding in an exit() override to detect it.


--
I do have a cause though. It's obscenity. I'm for it.
    - Tom Lehrer

Reply via email to