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

David Cantrell <[email protected]> Tue, 8 Mar 2022 23:55:53 +0000
Newsgroups gmane.comp.lang.perl.perl-mongers.boston
Message-ID <[email protected]>
On 08/03/2022 22:17, Bill Ricker via Boston-pm wrote:
> On Mon, Mar 7, 2022 at 2:16 PM David Cantrell <[email protected]> wrote:
>> The best tool for this is Capture::Tiny.
>> I won't disagree with David.
> Capture and then test the caught value with an is() or like() is quite
> straight forward, so I still won't disagree with David.
> ...
> However OTOH, the testing community would likely recommend considering as
> the idiomatic and declarative testing way either
> 
> *Test::Most* & *Test::Exception* 's syntactic sugar *throws_ok() *
> 
>     throws_ok {block under test} qr/regex/, q(explanation);

I do both, and whichever one I use depends on the circumstances.

> or the post-modern *Test2::Tools::Exception* 's *dies*()
> 
> like(
>      dies { die 'xxx' },
>      qr/xxx/,
>      "Got exception"
> );

There's nothing post-modern about Test2! I don't think I'd want to use a 
post-modern testing tool which said "that's not really a failure, it's 
all subjective, and what is truth anyway" :-)

Using Test2's `dies` like this is fine, but where Test2 really comes 
into its own IMO is in its improved tools for mocking.

-- 
David Cantrell