Eric Hodel
7/6/2007 8:26:00 PM
On Jul 4, 2007, at 16:54, Frew Schmidt wrote:
>> I would use a set of predefined "random" dates for tests. The
>> reasoning
>> (why not just use randomly generated dates?) is that if a test
>> fails, it
>> should be reproducible. It would be harder to debug a test that
>> sometimes fails.
>>
>> Dan
>
> Well the problem is that they will all fail eventually. This is the
> deal, we have date X, let's say that it's yesterday. My program uses
> some SQL statements to check if date X (which is obviously in a
> database) was within Y amount of days. But date X will no longer
> be in
> that range after so many days, so I either have to make it dynamically
> generated (no fun and possible error prone) or somehow make the
> computer
> think that the current date and time is a certain value.
You should test just the SQL statement, not its results. Let
somebody else worry about making sure the DB returns the right stuff.
This may mean you need to stub the DB interface to record your
queries and return your bogus results, but that should only take a
handful of extra lines.
--
Poor workers blame their tools. Good workers build better tools. The
best
workers get their tools to do the work for them. -- Syndicate Wars