On 2013-04-03 20:08, Jonathan M Davis wrote:

In general, I agree, because I think that straight-forward tests that avoid
loops and the like are far less error-prone, and you need the tests to not be
buggy. I don't want to have to test my test code to make sure that it works
correctly.

However, I _do_ think that there's something to be said for refactoring the
tests later (after the code supposedly fully works) to use loops and other
more complicated constructs, because not only can that lead to more compact
tests, but it also makes it much easier to make the tests more thorough
(without taking many more lines of code). I just think that _starting out_
with the more complicated tests is not necessarily a good idea. Treating unit
testing code as if it were the same is normal code doesn't make sense to me,
if nothing else, because that would indicate that you're going to have to test
your test code, since normal code is complicated enough to require testing.
But Andrei and I have argued about this before, and I don't expect us to agree
ever on it.

I do refactor tests, but mostly the data. At work I think we have pretty DRY tests, mostly the data. Using factories and other functionality to keep the code simple and DRY. "validate_postal_code" is a function written specifically for the tests above to keep it DRY.

--
/Jacob Carlborg

Reply via email to