I'm starting to have difficulty testing my apps by seat-of-the-pants methods, and figured it's about time to start learning how to use proper tests in Perl. I've looked at various docs, including the Test::Tutorial POD, and Test::Simple and Test::More, and some other Perlmonks threads that didn't really cover this.

What I'm not grasping is how one would use these in a CGI enviroment, esp. with backend database access as well. If, in order to do the most basic test, I need to set/read cookies, retrieve session info and user access levels from a DB, and that sort of thing, it seems like it would be really hard to do. And that doesn't even consider testing an app that generates forms and then processes/returns results from a database, or, worse, testing something that adds data to a database.

I suppose one could use something like WWW::Mechanize to perform tests on running CGI apps, but this seems like a different thing than creating and running a test suite.

My immediate inspiration is that I have a search function that allows a user to search on various fields, and after running with no problems for some time, I got a failure because one of the lesser-used fields had an improper verification routine attached to it, and it took a long time before someone chanced to enter just the right improper value to trigger the failure. But I couldn't figure out how to create a non-manual test for this.


In reply to Tests for CGI apps by jest

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.