For #1,

It also means that the test data is separate from the container.t file, so it would be easy for the two to get out of sync.

Your data in a test file should not become out of sync if you are properly managing your tests. The tests are there to point out your short-comings and that would include problems with your test data.

For #2, if you cannot keep your data straight in a seperate test file why should generating an input file should be superior? You can make mistakes with the test file that you generate and add another area you have to debug.

For #3, I would only use the Mock tests when you have to replicate an environment that needs a special setup and will not run any other way. An example, a module that you have to run with mod_perl on Apache. When you are running your tests during the build process it obivious you don't have mod_perl so the Test::Mock* would be good here.

for #4, I would not extend code in my modules to support testing. Debugging, yes, testing, no. It means that you have not thought enough about how to setup your tests.

For #5, like #4 you are changing your code to support testing and would advise against it.


If you are going to run a comprehensive test suite with randomly generated data, I would suggest generating a test file, otherwise stick with a static pregenerated test file.


In reply to Re: Testing methods that read input from files by Herkum
in thread Testing methods that read input from files by bobf

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.