On Wed, Aug 25, 2010 at 3:08 PM, Justin Harris <jharris(a)redhat.com> wrote:
All,
I have seen some use of random number/name generation used in tests
recently and want to discuss it further here. I am
going to go out on a limb and give the opinion that this is not a good
thing, and sets a
bad precedent. I think that the real value of tests is that they are an
easily repeatable, consistent assessment of where
the code is at a certain point in time. Tests really start to lose their
value when two runs of the same test on the same
code base can result in two different outcomes. I know that for things
like name generation this probably won't happen,
but as I said it is starting down a slippery slope, and IMHO we should
avoid it if possible.
Note that there is nothing wrong with *arbitrary* values, or values
determined at random and hard coded into tests - let's
just be sure that they are the same on subsequent runs of the same test.
Thoughts?
- Justin
Any examples where this has or could go wrong? I can't really see the
slippery slope here.
I find the random strings preferable to littering the code with
hardcoded "bob"'s and "someproducts"'s that we truly don't
care about.
They just get copy pasted everywhere and often clash at some point.
Cheers,
Devan
--
Devan Goodwin <dgoodwin(a)rm-rf.ca>
http://rm-rf.ca