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
98       check.
99

SEE ALSO

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

AUTHOR

126       Tom Moertel (tom@moertel.com)
127

INSPIRATION

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