1 00:00:00,570 --> 00:00:05,610 Previously, you've used breakpoints to fix bugs, but now you're going to use unit testing to avoid 2 00:00:05,610 --> 00:00:10,050 bugs in this lesson, you're going to understand the importance of unit testing. 3 00:00:14,920 --> 00:00:17,350 Manual testing means running your code. 4 00:00:20,710 --> 00:00:22,750 The output determines if you have a bug. 5 00:00:24,060 --> 00:00:26,670 But the output doesn't tell you where the bug is. 6 00:00:29,110 --> 00:00:34,480 For example, I assume you've written a lot of code, then you run your application and the output determines 7 00:00:34,480 --> 00:00:35,380 you have a bug. 8 00:00:36,070 --> 00:00:37,640 OK, where's the bug? 9 00:00:38,230 --> 00:00:42,290 Now you have to inspect every single line of code to find your bug. 10 00:00:43,120 --> 00:00:44,170 This is terrible. 11 00:00:47,710 --> 00:00:50,170 Unit testing helps you avoid bugs. 12 00:00:51,710 --> 00:00:55,910 Unit testing means every small unit of your application has a test. 13 00:01:05,030 --> 00:01:10,700 As soon as you make a mistake, one of your tests is going to fail, the failing test tells you where 14 00:01:10,700 --> 00:01:11,750 you made a mistake. 15 00:01:13,870 --> 00:01:17,800 For example, as you're writing code, you make a mistake. 16 00:01:22,450 --> 00:01:28,720 The test for that unit of code fails immediately, the failing test tells you to fix your mistake. 17 00:01:33,940 --> 00:01:35,920 Once you fix it, the test passes. 18 00:01:37,220 --> 00:01:41,930 If every test passes, then, you know, your application doesn't have any bugs and you can continue 19 00:01:41,930 --> 00:01:43,570 coding with peace of mind. 20 00:01:47,760 --> 00:01:49,930 So what is the importance of unit testing? 21 00:01:50,400 --> 00:01:56,040 What if I don't unit test, you're going to hesitate to add code from fear of getting bugs. 22 00:01:56,280 --> 00:01:59,430 You're always going to be scared that one day your OP is going to break. 23 00:02:01,870 --> 00:02:06,250 But what if you do unit test, in that case, you'll never get bugs. 24 00:02:06,550 --> 00:02:08,590 Your code is always going to be polished. 25 00:02:13,260 --> 00:02:20,310 Unit testing helps you avoid bugs, every small unit in your application should have a test if you make 26 00:02:20,310 --> 00:02:27,420 a mistake, the test for that unit fails when you fix your mistake, the test for that unit passes. 27 00:02:27,960 --> 00:02:31,800 If every test passes, then your application doesn't have any bugs.