Comparison
Characterisation testvsSeam
Characterisation test
you did not know what the function was supposed to do, so you wrote down what it currently does.
A test that records the existing behaviour of code, correct or not, so that a refactor can be shown not to change it. It is the standard first move in untested legacy code: you are not asserting the behaviour is right, only that you have not altered it. Bugs found this way get recorded as tests too, because in a system this old somebody downstream may already depend on them.
Full entry →Seam
you needed to test the payment path and there was nowhere to slip a fake in without editing the code you were testing.
A place where you can change behaviour without editing the code at that place — a parameter, an interface, a configuration point. Seams are what make legacy code testable, because they are where a real dependency can be replaced with a fake. Finding or creating a seam is usually the first move when changing code nobody dares touch, and the absence of seams is exactly what makes such code frightening.
Full entry →