I take the path of least work. If it's less work for me to produce more 'ok's, then that's the path I take. I'm not going to go out of the way to produce extra 'ok's, just to run up the number -- but likewise, I'm not going to go out of my way to keep the number down, either.

For instance, I have some routines which do transformations of query parameters to a search engine. Some of the functions handle the translation of spectrum parameters. I probably could have done something to write out one 'ok' for the whole thing, but it was easier for me to use the following, which generates 3 'ok's per 'wave_equiv()'

use Test::More; # waveunit must match sub wave_near { my ($wave1, $wave2, $precision, $name) = @_; my $pass = 1; if (!UNIVERSAL::isa($wave1, 'HASH') || !UNIVERSAL::isa($wave2,'HASH' +)) { ok(0); ok(0); ok(0); diag "\nnon-hash: $name\n"; return 0; } foreach my $field (qw(wavemin wavemax)) { my ($val1, $val2); $val1 = $wave1->{$field} if (exists($wave1->{$field})); $val2 = $wave2->{$field} if (exists($wave2->{$field})); do { $pass = 0; diag "\n$field mismatch\n"; } unless near ( $val1, $val2, $precision, $name." ".$field ); } do { $pass = 0; diag "\nwaveunit mismatch\n"; } unless is ( $wave1->{'waveunit'}, $wave2->{'waveunit'}, $name.' waveuni +t' ); return $pass; } # waveunit doesn't need to match. sub wave_equiv { my ( $wave1, $wave2 ) = ( shift, shift ); require Physics::Solar::VSO::QueryManipulate; ($wave1, $wave2) = Physics::Solar::VSO::QueryManipulate::AlignSpectr +alUnits( $wave1, $wave2 ); return wave_near( $wave1, $wave2, @_ ); } sub near { my ($val1, $val2, $precision, $name) = @_; # diag ( sprintf ( "\nnear called : %s : %s : %s : %s\n\n", $val1||'' +, $val2||'', $precision||'', $name||'') ); if (!defined($precision)) { $precision = 0.999999 } elsif ( $precision < 0.5 ) { $precision = 1 - $precision; } elsif ( $precision >= 1 ) { $precision = 1 - ( 10 ** -$precision ); } elsif ( $precision <= 0 ) { $precision = 1 - ( 10 ** $precision ); } return ok (1) if (!defined($val1) and !defined($val2)); if (!defined($val1) or (!defined($val2))) { diag "$name : undefined comparison\n"; return ok (0); } ($val1, $val2) = ($val2, $val1) if ($val1 > $val2); return cmp_ok( ($val1), '>=', $precision*$val2, $name ); }

I have other tests that test to see if a query is equivalent, that currently results in 28 'ok's per test case -- and that's bound to go up as we add more valid search parameters. All that I care about is that I don't have any errors. I couldn't care about how many not errors I have, so long as the number of errors stays 0.


In reply to Re: Testing at the right granularity by jhourcle
in thread Testing at the right granularity by polettix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.