This is a piece of advice I'd seen somewhere once, but can't remember where (or if this is exactly how it was worded). Does anyone know of an article or something that talks about this, or a more well-known term for this idea?
The basic idea: Say you have some code like:
def square(x):
return x ^ 2
A test like:
def test_square():
for inp in [3, 4, 5, 50, 100]:
assert square(inp) == inp ^ 2
is "well-factored", in that it doesn't have a lot of repetition, but isn't a great a test, since it's basically testing that the function's code does what the function's code does.
A better test would be something like:
def test_square():
assert square(3) == 9
assert square(4) == 16
assert square(5) == 25
# ...
because, for one, it would expose the bug (^ is XOR in Python, not exponentiation).