I can't count the modules I've installed from CPAN, and mostly they just installed just fine with either cpan Some::Module or downloading them and doing perl Makefile.PL && make && make test && sudo make install

But some didn't. In those cases, I got errors you know along the lines

t/025_some_test............ok 1/256 + # Failed test in t/025_some_test.t at line 7235. # got: 'FOO' # expected: 'BAR' # Looks like you failed 1 test of 256. t/025_some_test............dubious + Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 123

OK, fine. Invoke $EDITOR and look at line 7235. Maybe you can figure what went wrong. Maybe you can't, because the module's author has been a bit too terse for your knowledge. You could get hints from the SYNOPSIS section of the module's pod, but sometimes you just won't without grokking the entire module.

Now, as test files are valid perl files, the author could have just placed some pod along the lines of their test files. Wouldn't that be handy? You could then just say perldoc t/025_some_test.t and get a description about the test being performed, see which test does what, and an explanation of the test and maybe failure conditions. Since writing test files requires some thinking, the thoughts could just be documented by writing them as pod sections into the test files whilst composing those files. The script h2xs could write stubs for that into the initial test file.

I would advocate documenting test scripts as a First Best Practice for module authors. What do you think about it?

--shmem

update: Test files (could) give much more insight into a module's usage than can ever be placed into a module's pod without it being overburdened. That's another reason.

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

In reply to document your test files by shmem

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.