Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

[solved] Test module to compare results between different runs (save/load)

by Dallaylaen (Chaplain)
on Oct 03, 2018 at 12:58 UTC ( #1223460=perlquestion: print w/replies, xml ) Need Help??

Dallaylaen has asked for the wisdom of the Perl Monks concerning the following question:

Hello dear esteemed monks!

Update: Test::Regression

Is there already a module that allows to run a piece of code and, depending on arguments, either write results to a file, or compare with a previous such file? And is there a name for the concept in general? Searching for save load test on CPAN was somewhat cluttered...

So I need something along the lines of:

use Test::More; use Test::SaveLoad; use My::Module; # system under test # load previous results & compare my $sl = Test::SaveLoad->new( load => $filename ); # save results for future (in Dumper?..) my $sl = Test::SaveLoad->new( save => $filename ); # do actual testing plan tests => 1 if $sl->is_testing; $sl->test( "Basic usecase" => sub { My::Module->load_data( id => 42 ); }); # returns eq_or_diff-like line-by-line comparison

It's not that hard to write, but maybe there is something like that?

thank you

  • Comment on [solved] Test module to compare results between different runs (save/load)
  • Download Code

Replies are listed 'Best First'.
Re: Test module to compare results between different runs (save/load)
by choroba (Archbishop) on Oct 03, 2018 at 13:10 UTC
    This process is well known under the name "Regression Testing". See Test::Regression for a Perl implementation.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      Thanks!

      (Although I thought regression testing is a more general concept, just "find out if we broke something")

        ... I thought regression testing is a more general concept, just "find out if we broke something" ...

        It is (see Regression testing). (I like the word "just" in that quote.) In the most common notion of regression testing, you attempt to define all critical inputs and their correct outputs, a test set that can grow very large. (Can we call this "absolute" regression testing?)

        In the process you describe in the OP, you "just" take some input data set, run it through a process, and whatever the heck the output is, that's the correct output; if the next run has a different output, something broke. (Perhaps we can call this "differential" regression testing.)


        Give a man a fish:  <%-{-{-{-<

Re: [solved] Test module to compare results between different runs (save/load)
by 1nickt (Abbot) on Oct 03, 2018 at 15:07 UTC

    Hi, if you are using a newish Perl you can apply the --state flag to prove, with options governing which tests to rerun and compare with the previous run's state.

    See https://perldoc.perl.org/5.26.0/prove.html#--state for more.

    Hope this helps!


    The way forward always starts with a minimal test.
      That's not what I was asking for, but I definitely need to check it out. Looks quite useful. Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1223460]
Approved by marto
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-01-18 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (54 votes). Check out past polls.

    Notices?