Re: [Boston.pm] test::something that captures/hide expected stderr

"Morse, Richard E.,MGH via Boston-pm" <[email protected]> Wed, 9 Mar 2022 14:44:17 +0000
Newsgroups gmane.comp.lang.perl.perl-mongers.boston
Message-ID <[email protected]>
> On Mar 8, 2022, at 5:17 PM, Bill Ricker via Boston-pm <[email protected]> wrote:
> 
> or the post-modern *Test2::Tools::Exception* 's *dies*()
> 
> like(
>    dies { die 'xxx' },
>    qr/xxx/,
>    "Got exception"
> );

If you’re not looking per se at dying, but warnings, there is an equivalent for warnings.

In particular, I have the following test to test something about a module I wrote (this is part of a larger test file):

use Test2::V0;
use Test2::Tools::Spec;
use MGH_Biostat::Locale::POCatalog;

describe 'lookup' => sub {
	…

    tests 'invalid_lang' => sub {
        …

        is(
            warnings { $ret = $catalog->lookup( 'inv', 'test' ); },
            [ match qr/^Language inv not supported./ ],
            'invalid language warns'
        );
    };
};


Test2::Tools::Spec is what adds the extra ‘describe’ and ‘tests’ keywords. Test2::V0 imports all the various keywords like ‘is’ and ‘warnings’, etc.

With regards to your initial question, I thought that “prove” did print out a summary of everything passing ok?

Ricky
The information in this e-mail is intended only for the person to whom it is addressed.  If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Mass General Brigham Compliance HelpLine at https://www.massgeneralbrigham.org/complianceline <https://www.massgeneralbrigham.org/complianceline> .
Please note that this e-mail is not secure (encrypted).  If you do not wish to continue communication over unencrypted e-mail, please notify the sender of this message immediately.  Continuing to send or respond to e-mail after receiving this message means you understand and accept this risk and wish to continue to communicate over unencrypted e-mail. 

_______________________________________________
Boston-pm mailing list
[email protected]
https://mail.pm.org/mailman/listinfo/boston-pm