I have written simple Perl test case Example:
use Test::More;
is(2 + 4, 5, "Addition check");
output on the screen:
Failed test 'Addition check'
at t/simpel_perl_test.t line 2.
got: '6'
expected: '5'
Now I want to print a message in log file and on screen ?
I am not able use existing Perl modules IO::Tee
in <test case name>.t
to achieve my requirement.
Could you tell how could I write a message on screen and in a log file in Perl test case?
Command used:
prove -r --timer t/simpel_perl_test.t :: -d
The
IO::Capture
modules were written exactly for doing this during test execution. Start by readingIO::Capture::Overview
. However you appear to want the test harnesses output to be sent to a file instead. Maybe you want to provide a formatter argument toprove
that could write to a file. You could follow up theprove
invocation withcat
ing the file. Try the TAP::Formatter::File module as your argument, though I can't easily see how the file gets named.Wouldn't it just be best to use the
tee
command for this?