It happens. You open a project for the first time, maybe it’s a new client or your first day on the job, fire up the tests and… there aren’t any. Or at best there are a scattered few.
What in the world do you do now? Start writing a complete test suite from scratch? Except the CEO was _really _psyched about getting that new feature deployed this month…
From a technical perspective, there’s nothing wrong with writing a comprehensive test suite, but if you go down that road you’ll be on that road for a while. Instead, start adding tests where you touch the code. A great place to start is with bugs. Find a bug? Write a test case that captures the failing condition, write the fix that passes the test, and voilà you’ve just _meaningfully _increased test coverage.
Add a feature? If nothing else write tests for the feature itself, and then you can start writing tests for integration points with the rest of the code. Keep it going like this and eventually you’ll find yourself with a comprehensive test suite without having to sacrifice months writing a test suite for code you’re not changing.
Until next week,
Ben, Co-founder & Chief Djangonaut
Learn from more articles like this how to make the most out of your existing Django site.
Our "This Old Pony" newsletter is the first and only publication dedicated to care and enhancement of "legacy" Django projects.