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).
This is of course a bit of a contrived, very simple example, so it might seem silly, but I think you can imagine more complex functions where it's less clear that "computing" the expected output in some way "cheats" the test.