Test::Regression3pm
Test library that can be run in two modes; one to generate outputs and a second to compare against them
Usage
use Test::Regression;ok_regression(sub {return "hello world"}, "t/out/hello_world.txt");
Version
Version 0.08
Overview
Using the various Test:: modules you can compare the output of a function against what you expect. However if the output is complex and changes from version to version, maintenance of the expected output could be costly. This module allows one to use the test code to generate the expected output, so that if the differences with model output are expected, one can easily refresh the model output.
Export
ok_regression
Functions
ok_regression
This function requires two arguments: a CODE ref and a file path. The CODE ref is expected to return a SCALAR string which can be compared against previous runs. If the TEST_REGRESSION_GEN is set to a true value, then the CODE ref is run and the output written to the file. Otherwise the output of the file is compared against the contents of the file. There is a third optional argument which is the test name.
Environment
Test_regression_gen
If the TEST_REGRESSION_GEN environment file is unset or false in a perl sense, then the named output files must exist and be readable and the test will run normally comparing the outputs of the CODE refs against the contents of those files. If the environment variable is true in a perl sense, then model output files will be overwritten with the output of the CODE ref.
Support
You can find documentation for this module with the perldoc command.
perldoc Test::Regression
You can also look for information at:
- •
-
RT: CPAN's request tracker
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Regression>
- •
-
AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/Test-Regression>
- •
-
CPAN Ratings
<http://cpanratings.perl.org/d/Test-Regression>
- •
-
Search CPAN
<http://search.cpan.org/dist/Test-Regression/>
Acknowledgements
- Some documentation improvements have been suggested by toolic (http://perlmonks.org/?node_id=622051).
- Thanks to Filip Graliński for pointing out I need to test against output of zero length and providing a patch.
- Thanks to Christian Walde for pestering me about newline Windows compatibility issues and for providing a patch.
Copyright & license
Copyright 2009-10 Nicholas Bamber.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
Releases
7 releases since Debian 7 (Wheezy); the text changed 5 times.