My question is along similar lines as, and was actually inspired by, Using Test::More to unit test T-SQL. I was wondering if any monks have experience writing tests for code that relies on externally controlled data sources?

My specific example is I'm writing modules to perform simple statistical analysis on .db files created by a bayesian spam filter. The big problem I see is these files are modified by the spam filter on a regular basis, so I can't simply take known values out of the .db and assume they will stay the same. Are there any standard practices for dealing with this type of thing? Perhaps I should create my own .db files specifically for testing?

Oh, and why can't I just insert then delete known values into the database and test on those? Because I'm afraid to modify the .db files for fear of breaking the seemingly fragile bayesian spam filter. :)


In reply to testing externally controlled data sources by revdiablo

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.