Ask HN: How to build a test harness for a legacy system?

1 points by marsrover ↗ HN
I'm working with a legacy system that has no automated testing. I have a section of code that I need to refactor or it is going to get increasing more coupled. First, I tried going through the Legacy Code Change Algorithm but when trying to break dependencies, I'm moving a lot of code around (maybe I'm doing it wrong?).

I'm starting to think now that it would be a good idea to build automated acceptance tests around the functionality that I want to refactor, before breaking dependencies. Should I revisit how I am breaking dependencies or would it be worthwhile to take this path?

Any other words of wisdom you can impart my way?

1 comment

[ 3.4 ms ] story [ 14.2 ms ] thread
If it's got a web interface I suggest starting with browser-based testing like Selenium. It won't be as good as unit tests but will catch the obvious fuckups. I plan on doing this to a legacy project at my employer's and I already know it would've caught a few production fuckups we had lately - 500 error on the homepage, etc.

This also means you don't even need to be familiar with the code base, but just know how to use the web interface as a normal user would.