DEVELOPER ESSENTIALS
Unit Testing in Python
Code Confidently and Break Stuff on Purpose
Introduction
For anyone unfamiliar with the concept, unit testing is the practice of writing a series of tests (or “assertions”) regarding the behavior of your code to ensure that everything works as expected. Unit tests can be run at any point, over and over again, to reinforce your confidence in what you’ve written and allow you to understand (and often redefine) how your code handles various scenarios. By comprehensively testing both the “happy path” and “edge cases”, you can protect your code against breaking changes in the future.
Why unit testing is essential
Without unit tests, it may be very intimidating for you to make a major change or addition to your project later on down the road without introducing other problems. […] With unit tests in place, you can confidently add functionality to your project later on and ensure that all of the assumptions you previously had about how your code behaves still hold true.
Personally, I heard about the basic concepts of unit testing well before I used them in the Python language. I would venture a guess that many others have had a similar experience. Despite this, I firmly believe that unit testing is the single most important programming concept I’ve ever learned. I’ve grown immensely as a developer since I started writing unit tests, and it has encouraged me to…