You are here

9 ways to test your spaghetti code

“Test the legacy code as well” has been a mantra for many years now. But how do you actually do that? When stuck with tangled legacy-spaghetti, it may be hard to see the way out. The path from struggling with your spaghetti into doing TDD is shorter than you think.

It's so easy to say that you should test code as you change it, now matter how legacy, but in a real-world project, you need to know some tools and techniques to be able to do that.

Many developers out there struggle with the impression that testing and TDD cannot work on their project. I’ll challenge that view and hopefully prove it wrong for most participants, and share the techniques and tricks I’ve used.

Key takeaways: 

  • Good design improves testability
  • You can get legacy code under test, although you sometimes must make some trade-offs
  • TDD is suitable for a legacy project