Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Unit test of script fails unless Test::Warnings is used?!

by wanna_code_perl (Friar)
on Oct 13, 2019 at 01:17 UTC ( [id://11107393]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11107393]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-25 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found