<p>Is there a Perl module that allows me to view diffs between actual and reference output of programs (or functions)? The test fails if there are differences.</p>

<p>Also, in case there are differences but the output is OK (because the functionality has changed) I want to be able to commit the actual output as future reference output.</p>

[{'answer_id': 66506, 'author': 'Xetius', 'author_id': 274, 'author_profile': 'https://Stackoverflow.com/users/274', 'pm_score': 2, 'selected': False, 'text': '<p>I tend to use more of the Test::Simple and Test::More functionality.  I looked at PerlUnit and it seems to provide much of the functionality which is already built into the standard libraries with the Test::Simple and Test::More libraries.</p>\n'}, {'answer_id': 66597, 'author': 'Michael Carman', 'author_id': 8233, 'author_profile': 'https://Stackoverflow.com/users/8233', 'pm_score': 4, 'selected': False, 'text': "<p>Perl has excellent utilities for doing testing. The most commonly used module is probably Test::More, which provides all the infrastructure you're likely to need for writing regression tests. The prove utility provides an easy interface for running test suites and summarizing the results. The Test::Differences module (which can be used with Test::More) might be useful to you as well. It formats differences as side-by-side comparisons. As for committing the actual output as the new reference material, that will depend on how your code under test provides output and how you capture it. It should be easy if you write to files and then compare them. If that's the case you might want to use the Text::Diff module within your test suite.</p>\n"}, {'answer_id': 68725, 'author': 'Yanick', 'author_id': 10356, 'author_profile': 'https://Stackoverflow.com/users/10356', 'pm_score': 2, 'selected': False, 'text': '<p>For testing the output of a program, there is <a href="http://search.cpan.org/dist/Test-Command/" rel="nofollow noreferrer">Test::Command</a>.  It allows to easily verify the stdout and stderr (and the exit value) of programs. E.g.:</p>\n\n<pre><code>use Test::Command tests =&gt; 3;\n\nmy $echo_test = Test::Command-&gt;new( cmd =&gt; \'echo out\' );\n\n$echo_test-&gt;exit_is_num(0, \'exit normally\');\n$echo_test-&gt;stdout_is_eq("out\\n", \'echoes out\');\n$echo_test-&gt;stderr_unlike( qr/something went (wrong|bad)/, \'nothing went bad\' )\n</code></pre>\n\n<p>The module also has a functional interface too, if it\'s more to your liking.</p>\n'}, {'answer_id': 69684, 'author': 'mdxi', 'author_id': 11164, 'author_profile': 'https://Stackoverflow.com/users/11164', 'pm_score': 2, 'selected': False, 'text': '<p>The community standard workhorses are Test::Simple (for getting started with testing) and Test::More (for once you want more than Test::Simple can do for you). Both are built around the concept of expected versus actual output, and both will show you differences when they occur. The perldoc for these modules will get you on your way.</p>\n\n<p>You might also want to check out the <a href="http://perl-qa.hexten.net/wiki/index.php/Main_Page" rel="nofollow noreferrer">Perl QA wiki</a>, and if you\'re really interested in perl testing, the perl-qa mailing list might be worth looking into -- though it\'s generally more about creation of testing systems for Perl than using those systems within the language.</p>\n\n<p>Finally, using the module-starter tool (from Module::Starter) will give you a really nice "CPAN standard" layout for new work -- or for dropping existing code into -- including a readymade test harness setup.</p>\n'}, {'answer_id': 69802, 'author': 'Ovid', 'author_id': 8003, 'author_profile': 'https://Stackoverflow.com/users/8003', 'pm_score': 3, 'selected': False, 'text': '<p>As mentioned, Test::Differences is one of the standard ways of accomplishing this, but I needed to mention PerlUnit:  please do not use this.  It\'s "abandonware" and does not integrate with standard Perl testing tools.  Thus, for all new test modules coming out, you would have to port their functionality if you wanted to use them.  (If someone has picked up the maintenance of this abandoned module, drop me a line. I need to talk to them as I maintain core testing tools I\'d like to help integrate with PerlUnit).</p>\n\n<p>Disclaimer:  while Id didn\'t write it, I currently maintain Test::Differences, so I might be biased.</p>\n'}, {'answer_id': 71235, 'author': 'Hinrik', 'author_id': 10689, 'author_profile': 'https://Stackoverflow.com/users/10689', 'pm_score': 2, 'selected': False, 'text': '<p>I question those of you who recommend the use of PerlUnit. It hasn\'t had a release in 3 years. If you really want xUnit-style testing, have a look at <a href="http://search.cpan.org/perldoc?Test::Class" rel="nofollow noreferrer">Test::Class</a>, it does the same job, but in a more Perlish way. The fact that it\'s still maintained and has regular releases doesn\'t hurt either.</p>\n\n<p>Just make sure that it makes sense for your project. Maybe good old <a href="http://search.cpan.org/perldoc?Test::More" rel="nofollow noreferrer">Test::More</a> is all you need (it usually is for me). I recommend reading the "<em>Why you should [not] use Test::Class</em>" sections in the docs.</p>\n'}]
['https://Stackoverflow.com/questions/66330', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9792/']