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

Re: Testing Output and Functionality

Thread Previous | Thread Next
From:
Jed Lund
Date:
April 24, 2012 09:28
Subject:
Re: Testing Output and Functionality
Message ID:
CAM4-=+Ny2Pvt_AWfb=RARaiy+oyfcP3cjgndqvGOKQVAdZK6Ng@mail.gmail.com
David,

Thank you for your suggestion.  I haven't gone down that road yet so I will
try it.

Best Regards,

Jed

On Tue, Apr 24, 2012 at 4:07 AM, David Golden <xdaveg@gmail.com> wrote:

> 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