1Test::Regression(3) User Contributed Perl Documentation Test::Regression(3)
2
3
4
6 Test::Regression - Test library that can be run in two modes; one to
7 generate outputs and a second to compare against them
8
10 Version 0.05
11
13 use Test::Regression;
14 ok_regression(sub {return "hello world"}, "t/out/hello_world.txt");
15
17 Using the various Test:: modules you can compare the output of a
18 function against what you expect. However if the output is complex and
19 changes from version to version, maintenance of the expected output
20 could be costly. This module allows one to use the test code to
21 generate the expected output, so that if the differences with model
22 output are expected, one can easily refresh the model output.
23
25 ok_regression
26
28 ok_regression
29 This function requires two arguments: a CODE ref and a file path. The
30 CODE ref is expected to return a SCALAR string which can be compared
31 against previous runs. If the TEST_REGRESSION_GEN is set to a true
32 value, then the CODE ref is run and the output written to the file.
33 Otherwise the output of the file is compared against the contents of
34 the file. There is a third optional argument which is the test name.
35
37 TEST_REGRESSION_GEN
38 If the TEST_REGRESSION_GEN environment file is unset or false in a perl
39 sense, then the named output files must exist and be readable and the
40 test will run normally comparing the outputs of the CODE refs against
41 the contents of those files. If the environment variable is true in a
42 perl sense, then model output files will be overwritten with the output
43 of the CODE ref.
44
46 Nicholas Bamber, "<nicholas at periapt.co.uk>"
47
49 Please report any bugs or feature requests to "bug-test-regression at
50 rt.cpan.org", or through the web interface at
51 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Regression
52 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Regression>. I
53 will be notified, and then you'll automatically be notified of progress
54 on your bug as I make changes.
55
56 testing of STDERR
57 The testing of stderr from this module is not as thorough as I would
58 like. Test::Builder::Tester allows turning off of stderr checking but
59 not matching by regular expression. Handcrafted efforts currently fall
60 foul of Test::Harness. Still it is I believe adequately tested in
61 terms of coverage.
62
64 You can find documentation for this module with the perldoc command.
65
66 perldoc Test::Regression
67
68 You can also look for information at:
69
70 · RT: CPAN's request tracker
71
72 http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Regression
73 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Regression>
74
75 · AnnoCPAN: Annotated CPAN documentation
76
77 http://annocpan.org/dist/Test-Regression
78 <http://annocpan.org/dist/Test-Regression>
79
80 · CPAN Ratings
81
82 http://cpanratings.perl.org/d/Test-Regression
83 <http://cpanratings.perl.org/d/Test-Regression>
84
85 · Search CPAN
86
87 http://search.cpan.org/dist/Test-Regression/
88 <http://search.cpan.org/dist/Test-Regression/>
89
91 Some documentation improvements have been suggested by toolic
92 (http://perlmonks.org/?node_id=622051).
93 Thanks to Filip GraliXski for pointing out I need to test against
94 output of zero length and providing a patch.
95
97 Copyright 2009 Nicholas Bamber.
98
99 This program is free software; you can redistribute it and/or modify it
100 under the terms of either: the GNU General Public License as published
101 by the Free Software Foundation; or the Artistic License.
102
103 See http://dev.perl.org/licenses/ for more information.
104
105
106
107perl v5.12.1 2010-07-17 Test::Regression(3)