Test::LectroTest::Property is a Perl module with properties that make testable claims about your software.
SYNOPSIS
use MyModule; # provides my_function_to_test
use Test::LectroTest::Generator qw( :common );
use Test::LectroTest::Property qw( Test );
use Test::LectroTest::TestRunner;
my $prop_non_neg = Property {
##[ x label("odd") if $x % 2;
$tcon->retry if $y == 0; # 0 can't be used in test
my_function_to_test( $x, $y ) >= 0;
}, name => "my_function_to_test output is non-negative";
my $runner = Test::LectroTest::TestRunner->new();
$runner->run_suite(
$prop_non_neg,
# ... more properties here ...
);
STOP! If you're just looking for an easy way to write and run unit tests, see Test::LectroTest first. Once you're comfortable with what is presented there and ready to delve into the full offerings of properties, this is the document for you.
This module allows you to define Properties that can be checked automatically by Test::LectroTest. A Property is a specification of your software's required behavior over a given set of conditions. The set of conditions is given by a generator-binding specification. The required behavior is defined implicitly by a block of code that tests your software for a given set of generated conditions; if your software matches the expected behavor, the block of code returns true; otherwise, false.
This documentation serves as reference documentation for LectroTest Properties. If you don't understand the basics of Properties yet, see "OVERVIEW" in Test::LectroTest::Tutorial before continuing.
Two ways to create Properties
There are two ways to create a property:
1. Use the Property function to promote a block of code that contains both a generator-binding specification and a behavior test into a Test::LectroTest::Property object. This is the preferred method. Example:
my $prop1 = Property {
##[ x = 0;
}, name => "thing_to_test is non-negative";
2. Use the new method of Test::LectroTest::Property and provide it with the necessary ingredients via named parameters:
my $prop2 = Test::LectroTest::Property->new(
inputs => [ x => Int ],
test => sub { my ($tcon,$x) = @_;
thing_to_test($x) >= 0 },
name => "thing_to_test is non-negative"
);
Both are equivalent, but the first is concise, easier to read, and lets LectroTest do some of the heavy lifting for you. The second is probably better, however, if you are constructing property specifications programmatically.
Product's homepage
Requirements:
· Perl