Previously, you've used breakpoints to fix bugs, but now you're going to use unit testing to avoid
bugs in this lesson, you're going to understand the importance of unit testing.
Manual testing means running your code.
The output determines if you have a bug.
But the output doesn't tell you where the bug is.
For example, I assume you've written a lot of code, then you run your application and the output determines
you have a bug.
OK, where's the bug?
Now you have to inspect every single line of code to find your bug.
This is terrible.
Unit testing helps you avoid bugs.
Unit testing means every small unit of your application has a test.
As soon as you make a mistake, one of your tests is going to fail, the failing test tells you where
you made a mistake.
For example, as you're writing code, you make a mistake.
The test for that unit of code fails immediately, the failing test tells you to fix your mistake.
Once you fix it, the test passes.
If every test passes, then, you know, your application doesn't have any bugs and you can continue
coding with peace of mind.
So what is the importance of unit testing?
What if I don't unit test, you're going to hesitate to add code from fear of getting bugs.
You're always going to be scared that one day your OP is going to break.
But what if you do unit test, in that case, you'll never get bugs.
Your code is always going to be polished.
Unit testing helps you avoid bugs, every small unit in your application should have a test if you make
a mistake, the test for that unit fails when you fix your mistake, the test for that unit passes.
If every test passes, then your application doesn't have any bugs.