Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

To amplify what choroba and davido said, unit tests would be those for your classes and methods (probably, depends on how isolated they are) and testing the “glue” as you say would be system testing. Here’s a naïve skeleton to do both that ought to help you get your head around it and some ways to organize it–

use strictures; # strict + fatal warnings use Test::More; use Capture::Tiny "capture"; ok 1, "1 is ok"; # Test simple truthiness. diag "Dialog always shows"; note "Notes show when running verbose tests"; # Isolate a batch of tests into a subtest. subtest "My unit tests" => sub { require_ok("DBI"); # Use your own package here. # Test methods/subs in as minimalistic/decoupled a way as possible +. done_testing(1); # + whatever you add. }; subtest "My system tests" => sub { my ( $out, $err, $exit ) = capture { system qw/ ls -l -A -f /; # Your program/glue here instead. }; is $exit, 0, "Executed normally"; ok ! $err, "Without errors"; like $out, qr/\n-rw/, "Found some read/write nodes... very clumsily"; done_testing(3); }; done_testing(3);
moo@cow[44]~/>prove pm-1113898 -v pm-1113898 .. ok 1 - 1 is ok # Notes show when running verbose tests # Subtest: My unit tests # Dialog always shows ok 1 - require DBI; 1..1 ok 2 - My unit tests # Subtest: My system tests ok 1 - Executed normally ok 2 - Without errors ok 3 - Found some read/write nodes... very clumsily 1..3 ok 3 - My system tests 1..3 ok All tests successful. Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.04 cusr + 0.00 csys = 0.07 CPU) Result: PASS

Further suggested reading: Re: why Test::More? (my $horn; $horn->toot;), Capture::Tiny, Test::Most.

(Update: fixed spelling of minimalistic+decoupled in code comment.)

In reply to Re: A brief question about testing/best practices by Your Mother
in thread A brief question about testing/best practices by Amblikai

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (4)
    As of 2021-01-16 23:30 GMT
    Find Nodes?
      Voting Booth?