1Test::LectroTest::CompaUts(e3r)Contributed Perl DocumentTaetsito:n:LectroTest::Compat(3)
2
3
4

NAME

6       Test::LectroTest::Compat - Use LectroTest property checks in a
7       Test::Simple world
8

VERSION

10       version 0.5001
11

SYNOPSIS

13           #!/usr/bin/perl -w
14
15           use MyModule;  # contains code we want to test
16           use Test::More tests => 2;
17           use Test::LectroTest::Compat;
18
19           # property specs can now use Test::Builder-based
20           # tests such as Test::More's cmp_ok()
21
22           my $prop_nonnegative = Property {
23               ##[ x <- Int, y <- Int ]##
24               cmp_ok(MyModule::my_function( $x, $y ), '>=', 0);
25           }, name => "my_function output is non-negative" ;
26
27           # and we can now check whether properties hold
28           # as a Test::Builder-style test that integrates
29           # with other T::B tests
30
31           holds( $prop_nonnegative );   # test whether prop holds
32           cmp_ok( 0, '<', 1, "trivial 0<1 test" );  # a "normal" test
33

DESCRIPTION

35       This module lets you use mix LectroTest property checking with other
36       popular Test::* modules.  With it, you can use is()- and ok()-style
37       assertions from Test::* modules within your LectroTest property
38       specifications and you can check LectroTest properties as part of a
39       Test::Simple or Test::More test plan.  (You can actually take advantage
40       of any module based on Test::Builder, not just Test::Simple and
41       Test::More.)
42
43       The module exports a single function "holds" which is described below.
44
45   holds(property, opts...)
46           holds( $prop_nonnegative );  # check prop_nonnegative
47
48           holds( $prop_nonnegative, trials => 100 );
49
50           holds(
51               Property {
52                   ##[ x <- Int ]##
53                   my_function2($x) < 0;
54               }, name => "my_function2 is non-positive"
55           );
56
57       Checks whether the given property holds.
58
59       When called, this method creates a new Test::LectroTest::TestRunner,
60       asks the TestRunner to check the property, and then reports the result
61       to Test::Builder, which in turn reports to you as part of a typical
62       Test::Simple- or Test::More-style test plan.  Any options you provide
63       to "holds" after the property will be passed to the "TestRunner" so you
64       can change the number of trials to run and so on.  (See the docs for
65       "new" in Test::LectroTest::TestRunner for the complete list of
66       options.)
67

TESTING FOR REGRESSIONS AND CORNER CASES

69       LectroTest can record failure-causing test cases to a file, and it can
70       play those test cases back as part of its normal testing strategy.  The
71       easiest way to take advantage of this feature is to set the regressions
72       parameter when you "use" this module:
73
74           use Test::LectroTest::Compat
75               regressions => "regressions.txt";
76
77       This tells LectroTest to use the file "regressions.txt" for both
78       recording and playing back failures.  If you want to record and play
79       back from separate files, or want only to record or play back, use the
80       record_failures and/or playback_failures options:
81
82           use Test::LectroTest::Compat
83               playback_failures => "regression_suite_for_my_module.txt",
84               record_failures   => "failures_in_the_field.txt";
85
86       See Test::LectroTest::RegressionTesting for more.
87
88       NOTE:  If you pass any of the recording or playback parameters to
89       Test::LectroTest::Compat, you must have version 0.3500 or greater of
90       LectroTest installed.  Module authors, update your modules' build
91       dependencies accordingly.
92

BUGS

94       In order to integrate with the Test::Builder testing harness (whose
95       underlying testing model is somewhat incompatible with the needs of
96       random trial-based testing) this module redefines two Test::Builder
97       functions (ok() and diag()) for the duration of each property check.
98

SEE ALSO

100       For a gentle introduction to LectroTest, see
101       Test::LectroTest::Tutorial.  Also, the slides from my LectroTest talk
102       for the Pittsburgh Perl Mongers make for a great introduction.
103       Download a copy from the LectroTest home (see below).
104
105       Test::LectroTest::RegressionTesting explains how to test for
106       regressions and corner cases using LectroTest.
107
108       Test::LectroTest::Property explains in detail what you can put inside
109       of your property specifications.
110
111       Test::LectroTest::Generator describes the many generators and generator
112       combinators that you can use to define the test or condition space that
113       you want LectroTest to search for bugs.
114
115       Test::LectroTest::TestRunner describes the objects that check your
116       properties and tells you how to turn their control knobs.  You'll want
117       to look here if you're interested in customizing the testing procedure.
118
119       Test::Simple and Test::More explain how to do simple case-based testing
120       in Perl.
121
122       Test::Builder is the test harness upon which this module is built.
123

AUTHOR

125       Tom Moertel (tom@moertel.com)
126

INSPIRATION

128       The LectroTest project was inspired by Haskell's QuickCheck module by
129       Koen Claessen and John Hughes:
130       http://www.cs.chalmers.se/~rjmh/QuickCheck/.
131
133       Copyright (c) 2004-13 by Thomas G Moertel.  All rights reserved.
134
135       This program is free software; you can redistribute it and/or modify it
136       under the same terms as Perl itself.
137
138
139
140perl v5.36.0                      2023-01-20       Test::LectroTest::Compat(3)
Impressum