I am trying to understand why there is such a thing as a .t file, as opposed to just using the .pl files. Are the .t files really the same as the .pl files but with embedded tests?

.t files are perl files. They have a different suffix to identify the fact they are tests, not production code.

When I "use" Test::Simple, Test::More, etc., in a .pl file and run it with Perl it produces test results. Likewise, running that same .pl file with prove will produce test results although the output appears different. What's the advantage of using prove? Why not simply use Perl?

We do use perl. The different extension simply indicates to the user or test harness (e.g. prove) that this is a test which should be run. Prove provides a useful summary of the results of running many test scripts. The test script output (TAP - test anything protocol) is human-readable, but more easily summarised by a program. That's what prove is. (The volume of test data can be large, a summary is generally more useful unless you're hunting specific failures).

Are tests embedded into production modules? If not, how does one test (verify) that the act of physically removing tests from production code didn't accidentally interject some errors?

There are modules for embedding tests, e.g. Test::Inline, but normally the production code is left alone. The production code is normally included into the the .t files via use, so the .t file can call exactly the same code which would run in production.

I understand that the use of t/ directories to contain .t files is a convention for normal module installation. My problem is that I am coming from the Win32 environment using the ActiveState installation and I therefore rely on ppm for my installs. I don't get to do the "make test" part of the installation so perhaps I just don't have a full appreciation of what testing does. But I do want to have that understanding as I am working on some code I would like to distribute. I am sure development will go better if I can embed testing in it.

Automated testing is a important and very useful to check you don't break existing code or re-introduce old bugs. Some people go overboard with it, always beware being over-zealous about a methodology or programming practice. But my opinion is that it is very useful, if for no other reason than when you're writing a module (and hence designing an API) it gives you experience in writing code which uses that API - which often leads to a rethinking and refinement process.

'make test' pretty much just runs prove, so you're not missing out on too much there.


In reply to Re: Testing - General Questions by jbert
in thread Testing - General Questions by TomKane

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.