On Tue, 18 Nov 2008 22:51:01 +0000,
ar*****@fas.com wrote:
I am told that I should use assertions in my testing. [...]
Assertions are not meant to be a form of error handling, and
generally should never be present in production code. They aren't
necessary, but can sometimes be helpful for sanity checks.
Assertions can be helpful when doing something like testing some
expression that, logically, should not fail. Take another example:
in C programming, it can be helpful to use assertions to ensure you
don't try to dereference NULL pointers (you should never do this),
thus making it easier to catch undefined behavior, letting you know
exactly where the problem occurred, should the assertion fail.
The problem is, because I test using a cut of live data, the data
always changes. Has anyone come up against this or have they
abandoned assertions generally?
On a more general note, how does one reconcile a changing data set with
testing driven development?
This seems to be a bit of a vague question. You should have an idea
of the type of data your application needs. You should then take
necessary steps to validate and/or sanitize the data appropriately.
Make sure to only escape data appropriately during output as well.
It's often easier to store raw data, and only escape as necessary.
--
Curtis
$email = str_replace('si g.invalid', 'gmail.com', $from);