Changing untested code, without breaking it
In general, Legacy Code was not designed to be testable. Putting the existing codebase into a test suite is a very challenging step.
Problem is: without tests, every code change is risky. How do you know if you broke something?
Let's see what can get in the way and how you can solve every obstacle. Let's put some automated tests on your codebase!
🎓 Related articles
- One way of refactoring untested code
You need to change code that's not tested. How do you know you didn't break something? Here is one concrete way to tackle the problem.
- Improve your refactoring and testing skills with the Expense Report kata
Watch Gregor Riegler refactor code with this coding exercise. Learn useful techniques from it.
- 3 must-watch talks on Legacy Code
I have hosted more than 37 speakers to talk about Legacy Code tips and tricks. Here is my top 3 of the talks you should probably watch!
- Testability, Empathy, and Safe Refactorings
4 great talks on Legacy Code that I had the pleasure to host. This edition particularly focuses on testing and refactoring.
A reflection on coaching, facts, and pragmatism. Which testing framework would I recommend to devs who are not familiar with testing?
- 4 tips to refactor a complex legacy app without automation tools
How do you refactor a complex legacy application when you can't rely on automation tools?
- What's the difference between Regression Tests, Characterization Tests, and Approval Tests?
You may have heard one or the others. Now you're confused: is there a difference? Nope! Let me explain…
- Keeping dependencies up-to-date
My recipe for recovering from outdated dependencies and keeping healthy habits
- Technical Debt, Rewrites, and Refactoring
5 great talks on Legacy Code that I had the pleasure to host. Learn how to prioritize Tech Debt and rewrite systems incrementally.
- Is it OK to change code for the sake of testing?
It seems necessary to start adding tests on this code… but what if it makes things worse?
- Work faster and safer on untested code with Overcommitting
A technique you can resort to when you need to make risky changes.
- The best way to start testing untested code
Should you write E2E tests to cover more cases faster? Or is there a better approach?
- 4 developers working their way through Legacy Code
Practice working with code you've never seen before helps make it easier. Here's my selection of videos that will expose you to seasoned developers doing that!
- 7 techniques to regain control of your Legacy codebase
Working with Legacy Code is no fun… unless you know how to approach it and get your changes done, safely.
- A quick way to add tests when code has database or HTTP calls
You need to fix a bug, but you can't spend a week on it? Here's a technique to isolate problematic side-effects and write tests within minutes.
- 5 coding exercises to practice refactoring Legacy Code
Feeling overwhelmed by your legacy codebase? These katas will help you learn how to tackle it.
- The key points of Working Effectively with Legacy Code
This book is a reference. Here's my summary of its salient points so you understand why it's so recommended.
- Use the Mikado Method to do safe changes in a complex codebase
When a codebase is large and complex, it's risky to big changes. Here's a structured way to approach the problem.
- 3 steps to add tests on existing code when you have short deadlines
Here's a recipe you can follow when you want to add tests on Legacy Code, but you don't have much time to do so.