I'm writing a set of modules that will function as sort of a data access API (mostly reading/writing data in an sql database) that will be used by other (yet-to-be-written) modules that will be developed to add capability to a web application that runs under mod_perl.

I am trying to come up with a way to build a framework that will let developers code and unit test their yet-to-be-written modules to extend the web application without having to use the actual API code (except for integration testing) and without apache/mod_perl.

I've written quite a few perl tests before and am familiar with and have used Test::MockObject, Test::MockModule, Test::More, etc., but thing I'm having a hard time trying to figure out is at a high level, how to structure this test framework in such a way that there's not a bunch of code duplication. I've used Test::Class a little, and maybe it is a good approach and I'm just not "getting it" enough yet.

One approach I've thought of doing is to write mock versions of all the API libraries that provide some means for controlling the return values and that don't do any real database access. Then, the test code would 'use' these rather than the real API modules, but this doesn't really feel like the best approach because there are too many unknowns at this point.

Are there any other good approaches to these sort of test frameworks? Any pointers to reading material or even what to search for on Google would be appreciated. I do have a copy of O'reilly's Perl Testing, which has been helpful.


In reply to Architecting a testing framework for an API by mp

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.