Comparison
Characterisation testvsGolden test
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 →Golden test
you save the current output to a file and the test just checks nothing changed, which is exactly what you want on a legacy refactor.
A test comparing output against a recorded reference. It is excellent for pinning behaviour you are about to refactor and for large outputs no one wants to assert field by field. It goes bad when updating the snapshot becomes reflexive, at which point the test records what the code does rather than what it should.
Full entry →