[Haskell-cafe] QuickCheck - Extracting data values from tests

Shae Matijs Erisson shae at ScannedInAvian.com
Thu Sep 2 10:09:57 EDT 2004

Jorge Adriano Aires <jadrian at mat.uc.pt> writes:

> Hello all,
> When using Quickcheck, is there some way to extract generated data values to 
> the IO Monad? 
> I know I can collect and print information about test cases, but that's not 
> enough. Data may be pretty complex, and there may be no parsers for it. If a 
> test suddenly goes wrong, just having it displayed doesn't seem that useful.

You may be interested in a QuickCheck hack of mine that saves the offending
data value to use immediately in the next test run.

You can get the current version with 
"darcs get http://thunderbird.scannedinavian.com/repos/quickcheck"
I've only used this for my own code, so I'd be interested in any feedback.

In some cases it's a lot easier to generate a value from a seed and size rather
than saving the value in some way that you can restore (ie functions).

I've been investigating doing test-driven-development with QuickCheck, saving
failing test cases is one step towards that goal. If you have more ideas on
that topic, I'd like to hear about it.

> Also, even when I'm implementing a generator, I want to see how it is
> working. Running a verboseCheck on some dummy property helps, but I may want
> to analyse the data, or some parts of it better - for instance, for many data
> structures I have alternative "show" functions that take parameters as
> arguments.

This isn't clear to me, can you give other examples?
Shae Matijs Erisson - Programmer - http://www.ScannedInAvian.org/
"I will, as we say in rock 'n' roll, run until the wheels come off, 
because I love what I do." -- David Crosby

More information about the Haskell-Cafe mailing list