develooper Front page | perl.qa | Postings from April 2012

Re: Testing Output and Functionality

Thread Previous | Thread Next
From:
David Golden
Date:
April 24, 2012 04:08
Subject:
Re: Testing Output and Functionality
Message ID:
CAOeq1c8XVayhtNQpnfsUNkCi3wLA34cUYZUbDH2oHZp3MwpF_g@mail.gmail.com
On Tue, Apr 24, 2012 at 12:35 AM, Jed Lund <jandrewlund@gmail.com> wrote:
> I understand that this is a fairly basic question but I am stuck trying to
> find the right path forward.

It's not entirely basic, because you're testing an array of three
"outputs" for each functionality test instead of just one.

I'd probably use Capture::Tiny:

    use Capture::Tiny qw/capture/;

    my ($out, $err, $result) = capture { your_code_here };
    # then test $out, $err, $result however you want

If that's repetitive, stick it in a loop or write a function to
abstract testing the three results against your expectations.

-- David

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About