Debugging is hard, testing is easy!
Sanket Saurav (~sanket) |
Take it from someone who has introduced an exorbitantly high number of bugs in empty files for most of his life: debugging is hard indeed. But since the dawn of time, developers have been debugging code: there's no escaping that. Software testing, as the elders would tell you, is one of the greatest weapons in your arsenal against those bugs. It's easy to write tests. It helps you write more robust software. And it really helps you sleep at night: and your on-call ops team would love you! But testing is also deeply mystified, unfortunately. Beginners, and sometimes even seasoned developers, generally have a difficult time just to get started: so they eventually miss out on this easy way to attain peace of mind.
This talks aims at removing all the mystery around software testing in Python, and give the attendees a head-start into the easiest way of writing tests for their code. As part of being a Python developer for the past 8 years and leading a team of developers building enterprise-grade software for the past 4 years, I've learnt immensely about the important role of software testing in building scalable, durable software; and also a better, pragmatic way of thinking about testing in Python. This talk aims at providing a distilled version of my learning to the audience: both beginners to Python, and seasoned Pythonistas.
The talk would broadly cover these topics:
- A formal way of thinking about software testing / Why you should even bother about writing tests?
- Writing the simplest of tests in Python / Brief exploration of
- Introduction to mocking in Python / In-depth exploration of
mockand how to effectively use it for mocking any type of scenario in your code
- Writing tests for complex applications / working code examples from real life — This section would contain walkthrough of tests written in a few real-life applications and Python libraries, and a discussion on how to add test coverage for things that might not seem very straightforward to mock in a unit test.
- A few (opinionated) recommendations about testing
Apart from providing to the audience an easy-to-grasp framework of thinking about software testing, this talk aims to teach by examples from real world. Complex and not so straightforward concepts would be explained with code samples and tests from production, so it's easy for the audience to truly grasp them. The talk also features anecdotes from my own experience in building software to give the audience better context.
This talk is intended for newcomers to Python (who might never have written a test yet), as well as experienced developers (who might not be writing tests effectively). There are no technical pre-requisites for this talk. The key takeaways would be patterns you can directly start using in writing tests for your own code.