I’ve been always thinking “Testing? I don’t need no freakin’ testing! I’m doing without it just fine!”
And then my code became long.
Now I realize why it is important to write tests. I’m always afraid a little change will result in breaking something. I really want to start writing tests. But the code base has become so large that I’m really overwhelmed. I don’t know where to start. And much of it I don’t even remember why I coded it that way so if I begin to go back and write tests, it will take forever.
Can someone provide advice on how to start writing tests if I already have a large code base?
First, I would recommend reading the WELC book, which should really come in handy in your situation.
Start the next time you touch the code, the very next time you need to change something in the code, go write a test for it first and then continue to write tests surrounding everything that you have to change, update, fix, or add. That way, over time you will have added tests to all the areas that are changing and will get to a point when writing tests for the rest of the code doesn’t seem so overwhelming.
However, I would reiterate that the book I linked to how legacy code would be very helpful as it goes into lots of detail about ways to approach this issue.