On 07/03/2022 19:03, [email protected] wrote:
Another issue I'm running into is that I'm doing a lot of negative testing.
I'm testing a module I wrote and making sure it errors out when given
bad data.
According to Test::More, the way to do that is:
ok !eval {myfun("bad", "data"); 1}, 'test bad data';
The annoying thing is that myfunc() prints out a bunch of error messages
which show up on my terminal when I run mytest.pl script.
So, I run mytest.pl, see a bunch of errors, and it's not immediately clear
those messages are expected.
The best tool for this is Capture::Tiny. You can capture STDOUT and
STDERR into variables and then check that they are as expected. See for
example
https://metacpan.org/release/DCANTRELL/CPAN-FindDependencies-3.10/source/t/cpandeps-diff-script.t
--
David Cantrell
_______________________________________________
Boston-pm mailing list
[email protected]
https://mail.pm.org/mailman/listinfo/boston-pm