nysus has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to generate cleaner test output to minimize distracting messages. I've got the following test which is that is meant to fail using Test::Exception:

throws_ok { my $wsr = WebServerRemote->new(ssh => 'me@10.0.300.99') } +qr {could not connect}, 'complains if unable to connect';

This test is for the following lines:

my $ssh = Net::OpenSSH->new($host, %opts); $ssh->error and croak "could not connect to host: $ssh->error";

I get the following output from my test:

ssh: Could not resolve hostname 10.0.300.99: nodename nor servname pro +vided, or not known

If possible, I'd like to suppress that message generated by Net::OpenSSH (and others from other modules) in my tests but leave it for real world operation, if at all possible.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re: Tips for quieting test exception output?
by nysus (Parson) on Feb 28, 2017 at 02:00 UTC

    So turns out Net::OpenSSH has a way to discard errors sent to STDERR.

    So doing this:

    throws_ok { my $wsr = WebServerRemote->new(ssh => 'me@10.0.300.99', ma +ster_stderr_discard =>1) } qr {could not connect}, 'complains if unable to connect';

    along with some proper argument handling, did the trick.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

Re: Tips for quieting test exception output?
by Anonymous Monk on Feb 28, 2017 at 18:06 UTC
    This test has no value.