Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

What Test::LectroTest is all about

by tmoertel (Chaplain)
on Nov 14, 2005 at 22:26 UTC ( #508429=note: print w/replies, xml ) Need Help??

in reply to Re: Test::LectroTest and pseudo random distributions
in thread When test-driven development just won't do

xdg wrote
I think I just don't "get" Test::LectroTest.
Maybe this will help.

I wrote LectroTest because I wanted an alternative to traditional, case-based unit testing that offered markedly different cost, benefit, and mental models for testing. There are many times when case-based testing sucks, and for these times LectroTest offers programmers another option. The two approaches complement each other and can even be seen as duals.

The LectroTest approach requires programmers to be explicit about what their programs are supposed to do. Programmers must write property specifications that define the required behaviors of their programs. Then LectroTest uses random sampling to automate the process of gathering evidence to support (or refute) the claims made by the property specifications.

Case-based testing, on the other hand, requires programmers to write individual test cases that each provides incremental evidence for (or against) some implied claim of overall correctness. Together, the test cases represent an implicit definition of correctness, but such definitions are usually difficult to extrapolate from the cases and often are nebulous and incomplete, which isn't necessarily a bad thing: in real life, formal notions of correctness may be hard to define.

A table makes the salient differences easy to see:

LectroTest Case-based testing
Definition of correctness Explicit
(via hand-written properties)
(via manual extrapolation)
Test cases Implicit
(automatically generated)
(written by hand)

Which approach is best depends on what you are doing. As a rule of thumb, if you can easily specify what a piece of code ought to do, there's a good chance that LectroTest will be a great way to test that code. If, however, you are working on code for which correctness is a difficult concept to formalize, case-based testing will probably be the more fruitful approach.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://508429]
Discipulus puts on AC hoping it goes better..
[Eily]: you should use DC instead, less variation
[Discipulus]: surprisingly i put ADCD in this precise moment!

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2017-06-26 11:32 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (577 votes). Check out past polls.