I had a time-sensitive fix to a calculation that needed to be applied to a complicated calculation for a highly complex application. We’re helping someone account for money that runs their business and the result gets exposed to clients and sent out on an invoice, so I had to ensure that my fix didn’t cause more bugs elsewhere, and ensure that the calculation is functioning accurately.
On large-scale applications with complex business requirements and multiple developers, you have to be able to respond to changing requirements by making changes to existing code. While the change may not seem significant, the impact of that change may turn out to be.
Hence, the need for a unit test.
Good coverage with your unit tests enforces good custom app development practices, keeps your developers from stepping on each other’s toes, and gives you confidence that the changes that you make down the road will be non-breaking. It also allows you to reduce the amount of time you spend regression testing after a bug is fixed because that work is already automated by your unit test suite.
I was really glad to have the foresight to create unit tests for this project, and specifically this area of the application. If I hadn’t created those tests, we’d still be verifying the bug fix and its impact on other parts of the application.
Tl;dr – Unit testing saved the day and I could confidently make the bug fix without having to do a full regression test on the calculation for the application.