How do you add tests to code that was not designed to be tested?
Characterisation tests (also called Golden Master or Approval tests) work with untestable legacy code — run the code with representative inputs, record the outputs, and write tests that verify the same inputs produce the same outputs. This does not require the code to be well-structured or dependency-injected. It creates a regression baseline. As refactoring improves the code structure, traditional unit tests replace characterisation tests for the refactored components.