You could also address your concerns by refactoring your module a bit. Your module could have a subroutine/method to check that a file fulfils the criteria needed to be used by the module, whatever they are. Then there could be a separate sub/method that attempts to make a file compliant with your requirements and return "true" if it suceeds and "false" if it doesn't.
In your test script you would now create a good file and a bad file and the test would first assert that they are picked up accordingly by the checking-method.
Then you would pass the bad file through the secnod method and assert that it returns true. You should also create a file that can't be fixed and assert that your second method returns false on that one, meaning that the error can be picked up and handled.
Now you don't duplicate any code anymore, you just assert that your methods return the right thing.
You would then have something like:

ok( not file_is_usable( $bad_file ), "a bad file is identified correct +ly); ok ( make_file_usable ( $bad_file ), "can correct a bad file")
In addition, you have also made your methods more focused on one thing and reduced side-effects.


In reply to Re: Philosophical question about testing by tospo
in thread Philosophical question about testing by rastoboy

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.