I am trying to write characterization tests, in order to quickly put a legacy system to a test harness.
I was not able to find many examples with production code. The examples I find are small programs.
An example by an author of Working Effectively with Legacy Code implements them as unit tests.
It's nice because it's human-readable and help you understand the code. However, I think it would work for small programs in the example, but the system I am trying to test is a pretty complex API client.
Other examples store the inputs and outputs in files and read them to compare the results with the 'snapshots'.
Some examples are VCR, Approval Tests, Golden Master Testing
I feel like this allows the test input to be generated, and suitable for testing a large set of inputs.
However, for some reason it feels more high-level than unit testing, and not very human-readable.
Are these tests supposed to be part of your unit test suite, or are they supposed to be complements to unit tests?
In other words, should I sample some characteristic test inputs and write characterization tests as unit tests, but using the actual output from the code to 'lock down' the existing behaviors, and trying to make it readable? Or should I treat characterization tests as a complement to unit tests? If so, what should I focus on in my unit tests?