Don't ask to ask, just ask | |
PerlMonks |
Testing and database date functionsby relax99 (Monk) |
on Dec 09, 2004 at 16:27 UTC ( [id://413612]=perlquestion: print w/replies, xml ) | Need Help?? |
relax99 has asked for the wisdom of the Perl Monks concerning the following question: 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.
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!
Back to
Seekers of Perl Wisdom
|
|