Hello!

I am writing a test script for a Perl program that does database operations. The problem is that some of these operations depend on database's current date and dayofweek functions and I can not vary results from these.

The program reads two values from a table (for the current date and the next date) and then makes updates to a row in another table for the current date based on the data in these two rows. My initial solution was to create a test script that uses Test::Simple to test the actual result against the required result based on a set of predefined inputs and outputs.

Set 1: M T W T F S S Inputs: 1, 1, 0, 1, 0, 0, 0 Outputs: 1, 1, 0, 0, 0, 0, 0 Set 2: M T W T F S S Inputs: 1, 1, 1, 1, 1, 0, 0 Outputs: 1, 1, 1, 1, 1, 0, 0 Set 3: etc...

For instance, if the current day of week is Monday then the inputs are 1, 1 and the output should be 1. If the current day of week is Thursday then the inputs are 1, 0 (from set 1) and the output should be 0.

But, like I said, the Perl program uses sql with current date function in it, so I can't get the program to accept the inputs for arbitrary days of week.

How would you go about testing this program? Is it even possible? I could run the test every day for 7 days and that would test all combinations of inputs, but that seems to undermine the whole concept of testing where you should be able to run all of your tests and see if they succeed at any point in time, not over a period of so many days.

Please ask me for more details if something in the description of the problem is unclear to you.

Thanks!


In reply to Testing and database date functions by relax99

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.