“It is impossible BY DEFINITION to do Test-Driven Development after the code is written.” — Tim Ottinger, author of Clean Code, on Twitter 1.
Automated testing is one of the most important tools in the modern programming toolbox: good tests help you find regressions early, and help you make sure your code is right before it ships. Test-driven development is a great way to make sure your software is up to specification before you start work. Even better, it makes sure your software’s architecture is amenable to writing tests from Day 1.
So what happens when you find yourself working on code where automated testing took a back seat to being shipped? Chances are you’ll have a mess of bugs, strung together in a structure where writing simple unit tests just isn’t going to happen.
Broken code is a support burden, and if it’s in production, you’ve got no choice but to make things work. Luckily, automated testing isn’t a lost cause here!
In this talk, we’ll look at how to approach automated testing on late-stage, or even production code… or in any situation when you don’t have the luxury of starting with a test-driven structure. We’ll look at techniques that I’ve used to analyse faults in existing code, how to translate those into tests, and how to use that to fix bugs.
In particular, we’ll look at:
We’ll see that testing old code is both achievable, and actually a worthwhile exercise. You’ll find bugs. You’ll increase quality. You’ll make your code more maintainable! Do try it!
Christopher Neugebauer is an Australian programmer who lives in the Tasmanian city of Hobart. He currently works as an Android developer, which means his day job involves more Java than he would like. Christopher is strongly interested in developing the Australian and International Python and Open Source communities: he a past convenor of PyCon Australia, a board member of Linux Australia, and has been a fellow of the Python Software Foundation since 2013. He’s also director of linux.conf.au 2017, Australia’s grassroots Open Source Conference, to be held in Hobart in January 2017. In his spare time, Christopher enjoys presenting on mobile development at open source conferences, and presenting on open source development at mobile conferences.
©2015, O'Reilly Media, Inc. • (800) 889-8969 or (707) 827-7019 • Monday-Friday 7:30am-5pm PT • All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners. • email@example.com