Subject | How do I test date manipulation code |
---|---|
Author | Tim Ward |
Post date | 2013-10-29T12:05:09Z |
I've got a stored procedure which does some sums on dates, which are
passed in as parameters.
So far so good, I can test the procedure by running it under the
Database Workbench debugger, and typing in the values of the input
parameters, and seeing whether the output is as expected. Or I can
automate this by writing a unit test stored procedure.
**BUT** the stored procedure I want to test does different things
depending on what the date is today, which it determines using the 'NOW'
pre-defined date literal.
So how do I test this procedure? How do I get 'NOW', used within the
procedure, to produce different timestamps as needed for the various
test cases? (Without, of course, typing different things into the
procedure itself, thus introducing the risk of getting it wrong and
introducing bugs when I later remove the test code.)
--
Tim Ward
passed in as parameters.
So far so good, I can test the procedure by running it under the
Database Workbench debugger, and typing in the values of the input
parameters, and seeing whether the output is as expected. Or I can
automate this by writing a unit test stored procedure.
**BUT** the stored procedure I want to test does different things
depending on what the date is today, which it determines using the 'NOW'
pre-defined date literal.
So how do I test this procedure? How do I get 'NOW', used within the
procedure, to produce different timestamps as needed for the various
test cases? (Without, of course, typing different things into the
procedure itself, thus introducing the risk of getting it wrong and
introducing bugs when I later remove the test code.)
--
Tim Ward