1Test::LectroTest::FailuUrseeRrecCoorndterri(b3u)ted PerlTeDsotc:u:mLeencttartoiToenst::FailureRecorder(3)
2
3
4

NAME

6       Test::LectroTest::FailureRecorder - Records/plays failures for
7       regression testing
8

VERSION

10       version 0.5001
11

SYNOPSIS

13        use Test::LectroTest::Recorder;
14
15        my $recorder = Test::LectroTest::Recorder->new("storage_file.txt");
16
17        my $recorder->record_failure_for_property(
18           "property name",
19           $input_hashref_from_counterexample
20        );
21
22        my $failures = $recorder->get_failures_for_property("property name");
23        for my $input_hashref (@$failures) {
24           # do something with hashref
25        }
26

DESCRIPTION

28       This module provides a simple means of recording property-check
29       failures so they can be reused as regression tests.  You do not need to
30       use this module yourself because the higher-level LectroTest modules
31       will use it for you when needed.  (These docs are mainly for LectroTest
32       developers.)
33
34       The basic idea is to record a failure as a pair of the form
35
36        [ <property_name>, <input hash from counterexample> ]
37
38       and Dump these pairs into a text file, each record terminated by blank
39       line so that the file can be read using paragraph-slurp mode.
40
41       The module provides methods to add such pairs to a recorder file and to
42       retrieve the recorded failures by property name.  It uses a cache to
43       avoid repetitive reads.
44

METHODS

46   new(storage-file)
47         my $recorder = Test::LectroTest::Recorder->new("/path/to/storage.txt");
48
49       Creates a new recorder object and tells it to use storage-file for the
50       reading and writing of failures.
51
52       The recorder will not access the storage file until you attempt to get
53       or record a failure.  Thus it is OK to specify a storage file that does
54       not yet exist, provided you record failures to it before you attempt to
55       get failures from it.
56
57   get_failures_for_property(propname)
58         my $failures = $recorder->get_failures_for_property("property name");
59         for my $input_hashref (@$failures) {
60            # do something with hashref
61            while (my ($var, $value) = each %$input_hashref) {
62                # ...
63            }
64         }
65
66       Returns a reference to an array that contains the recorded failures for
67       the property with the name propname.  In the event no such failures
68       exist, the array will be empty.  Each failure is represented by a hash
69       containing the inputs that caused the failure.
70
71       If the recorder's storage file does not exist or cannot be opened for
72       reading, this method dies.  Thus, you should call it from within an
73       "eval" block.
74
75   record_failure_for_property(propname, input-hashref)
76         my $recorder->record_failure_for_property(
77            "property name",
78            $input_hashref_from_counterexample
79         );
80
81       Adds a failure record for the property named propname.  The record
82       captures the counterexample represented by the input-hashref.  The
83       record is immediately appended to the recorder's storage file.
84
85       Returns 1 upon success; dies otherwise.
86
87       If the recorder's storage file cannot be opened for writing, this
88       method dies.  Thus, you should call it from within an "eval" block.
89

SEE ALSO

91       Test::LectroTest::TestRunner explains the internal testing apparatus,
92       which uses the failure recorders to record and play back failures for
93       regression testing.
94

AUTHOR

96       Tom Moertel (tom@moertel.com)
97
99       Copyright (c) 2004-13 by Thomas G Moertel.  All rights reserved.
100
101       This program is free software; you can redistribute it and/or modify it
102       under the same terms as Perl itself.
103
104
105
106perl v5.32.0                      2020-07-2T8est::LectroTest::FailureRecorder(3)
Impressum