in reply to Can I use Test::Differences with Test::LectroTest?

I have created a new compatibility module that allows Test::LectroTest and the Test::* family of modules to be mixed together. The implementation relies upon a tiny element of hackishness right now but seems to work well.

The idea is that you build up test plans as usual with Test::More and friends. Just use Test::LectroTest::Compat if you want to use specification-based property checks as part of your plans. Define your properties in the usual LectroTest way and then use holds(property) assertions to insert property checks into your test plan. Properties that are checked within a holds assertion are free to call ok()-style assertions provided by Test::* modules (such as Test::Deep).

When invoked this way, LectroTest runs batteries of trials to check your properties, as usual, but instead of reporting the results of each battery using LectroTest's own reporting engine, it passes the result out to Test::Builder, which records and reports the result along with the rest of your plan's tests.

Give it a try and let me know what you think.

See the LectroTest FAQ list for more on the subject and info on where to download the (presently in-development) module.

Replies are listed 'Best First'.
Re: Try Test::LectroTest::Compat
by pernod (Chaplain) on Feb 17, 2005 at 18:11 UTC

    I didn't see this node until today. Sorry for the delay.

    Test::LectroTest::Compat fits the bill. I had to download the package from your website and install manually though, but this looks like an issue with my CPAN mirror. Anyhow, the above example with Test::Differences rewritten to Test::LectroTest::Compat:

    #! /usr/bin/perl use Test::More tests => 1; use Test::LectroTest::Compat; use Test::Differences; sub square { my $square = $_[ 0 ] * $_[ 0 ]; return [ $square, $square ]; } my $square_property = Property { ##[ x <- Int #]## my $sq = $x * $x; eq_or_diff( square( $x ), [ $sq, $sq ] ); }, name => "Finding \$x's square. Twice!"; holds( $square_property );

    Which gives me the expected:

    shiny:~/dev/perl$ perl lec.pl 1..1 ok 1 - property 'Finding $x's square. Twice!' (1000 attempts)

    Once again, thank you very much for a great module!

    pernod
    --
    Mischief. Mayhem. Soap.