in reply to Re: Unit test of script fails unless Test::Warnings is used‽
in thread Unit test of script fails unless Test::Warnings is used?!

I use Test::Exception all over this test suite. In fact, it was one of the use lines I deleted. :-)

Using it for the require test hadn't occurred to me, though. I'll switch to that. Thanks. Edit: How would I replicate the OP's BAIL_OUT semantics when using lives_ok?

Edit: Either you edited your reply, or I didn't see you answering the bit about why the test failed unless Test::Warnings was included. That makes perfect sense.

Replies are listed 'Best First'.
Re^3: Unit test of script fails unless Test::Warnings is used?!
by Your Mother (Archbishop) on Oct 13, 2019 at 01:28 UTC
Re^3: Unit test of script fails unless Test::Warnings is used?!
by 1nickt (Canon) on Oct 13, 2019 at 01:35 UTC

    "Edit: How would I replicate the OP's BAIL_OUT semantics when using lives_ok?"

    lives_ok sub { require 'script' } or BAIL_OUT("bin/script did not load: $@");
    :-)

    To make your test suite stop any time a test fails:

    use Test::Most 'die';
    (Although you cannot control the output as with BAIL_OUT, and it will apply to all tests in the file.)

    (Note that Test::Most loads Test::More and Test::Exception as well as others and warnings and strict.)

    Hope this helps!

    Update: showed one-test solution first


    The way forward always starts with a minimal test.
Re^3: Unit test of script fails unless Test::Warnings is used?!
by 1nickt (Canon) on Oct 13, 2019 at 01:27 UTC

    Because Test::Warnings runs a test of its own, so the harness is satisfied. Output of your test script using Test::Warnings under --verbose:

    $ prove -lrv 11107390.t 11107390.t .. ok 1 - no (unexpected) warnings (via done_testing) 1..1 ok All tests successful.

    Hope this helps!


    The way forward always starts with a minimal test.