Test::LectroTest::Tutorial

Test::LectroTest::Tutorial is a Perl module that contains documentation on how to use LectroTest to test your software.
Download

Test::LectroTest::Tutorial Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Tom Moertel
  • Publisher web site:
  • http://search.cpan.org/~tmoertel/Test-LectroTest-0.3500/lib/Test/LectroTest.pm

Test::LectroTest::Tutorial Tags


Test::LectroTest::Tutorial Description

Test::LectroTest::Tutorial is a Perl module that contains documentation on how to use LectroTest to test your software. Test::LectroTest::Tutorial is a Perl module that contains documentation on how to use LectroTest to test your software.SYNOPSISLectroTest is an automated, specification-based testing system. To use it, declare properties that specify the expected behavior of your software. Then invoke LectroTest to test whether those properties hold.LectroTest does this by running repeated random trials against your software. If LectroTest finds that a property doesn't hold, it emits the counterexample that "broke" your software. You can then plug the counterexample into your software to debug the problem. (It's also a good idea to add the counterexample to your list of regression tests.)Think of your software's behavior as a haystack that you're searching for needles. Each error is a needle. You want to find the needles and remove of them. LectroTest will search the haystack for you -- it's nice that way -- but first you must tell it about the shape of the haystack and how to recognize a needle when it sees one.The HaystackThe shape of the haystack is defined by a set of "generator bindings," in which variables are bound to the output of value generators: x = 0;The above asserts for each point in the haystack that the output of the function the_thing_we_are_testing must be non-negative.Put them together to make a PropertyThe generator bindings and needle recognizer are combined to make a property: Property { ####. This tells Perl that our bindings are bindings and not regular Perl code.)We can read the above property like so: "For all integers x and all characters c in the range A through Z, we assert that the_thing_we_are_testing is non-negative."Testing whether your Properties holdAfter you define properties for your software, just add them to a small Perl program that uses the Test::LectroTest module: # MyProperties.l.t use MyModule; # provides the_thing_we_are_testing use Test::LectroTest; Property { ##[ x = 0; }, name => "the_thing_we_are_testing(...) is non-negative";Then you can test your properties simply by running the program: $ perl MyProperties.l.tIf your properties check out, you'll see something like this: 1..1 ok 1 - 'the_thing_we_are_testing(...) is non-negative' (1000 attempts)If something goes wrong, however, LectroTest will tell you where it happened: 1..1 not ok 1 - 'the_thing_we_are_testing(...) is non-negative' falsified in 23 attempts # Counterexample: # $x = 4 # $c = "R"What this says is that at the point (x=4, c="R") in the haystack, there is a needle (i.e., your property doesn't hold). With this information, you can examine your code to determine the cause of the error. Requirements: · Perl


Test::LectroTest::Tutorial Related Software