--- Scene 1: Without writing unit tests ---
You: Phew! Finally my code is handling all the scenarios! commits the code
After few days...
Teammate: Hey bro, I want to introduce couple of changes in your code, I just want one use-case to handle in my task.
You: No Problem at all !
Teammate makes blunt changes in your code and the build is deployed and now your code started breaking in production on weekend...
You might argue that you didn't even touch the code for this release yet it happened. You spend hours figuring out why it happened. Suddenly you notice that the code change introduced by your teammate is the causing one of your use-cases to fail . There'll be some blame game between you two and blah blah, then you'll try to understand the context and after a day or two, the issue finally gets resolved.
--- End of Scene 1 ---
--- Scene 2: With writing unit tests ---
... ...
Teammate: Hey bro, I want to introduce couple of changes in your code, I just want one use-case to handle in my task.
You: No Problem at all !
After a while..
You: Hey, could you introduce the changes in my code?
Teammate: No bro, my changes are breaking tests, I'll introduce my changes carefully and write unit-tests for my changes too so that it won't break in future.
He'll introduce appropriate changes and the build process will be triggered. All tests will pass. Everyone will enjoy their great weekend
---End of Scene 2---
It can be your teammate or yourself who might introduce the flaw in the code. Unit tests will come really handy to detect functionality loopholes in your code way before the code is even deployed.
I hope I clarified your question.
P.S. Please excuse my informal way of answering the question. I was bored.
Vishwa Bhat
Technology Enthusiast