1 00:00:00,460 --> 00:00:03,280 The kind of automated test we'll learn to write in this course 2 00:00:03,280 --> 00:00:05,410 are called, Unit Tests. 3 00:00:05,410 --> 00:00:10,180 Unit Testing involves Writing tests that confirm an individual function or 4 00:00:10,180 --> 00:00:12,270 piece of code works the way we want it to. 5 00:00:13,350 --> 00:00:18,000 We write Unit Test for code that has a clear specific purpose, for example, 6 00:00:18,000 --> 00:00:22,210 we'll often write unit test for the individual functions in a program, 7 00:00:22,210 --> 00:00:26,380 the unit tests can then call the function without needing to run our entire 8 00:00:26,380 --> 00:00:31,270 application to make sure we know that the function behaves as we expect. 9 00:00:31,270 --> 00:00:34,360 Unit Tests are kind of like a basketball drill. 10 00:00:34,360 --> 00:00:38,780 As a basketball player, you need to master various skills like shooting, 11 00:00:38,780 --> 00:00:41,690 passing, running, dribbling and so on. 12 00:00:41,690 --> 00:00:44,700 Basketball players run specific drills to test 13 00:00:44,700 --> 00:00:47,860 each of these skills outside of an actual game. 14 00:00:47,860 --> 00:00:51,140 A basketball player might just practice free throws for a while and 15 00:00:51,140 --> 00:00:55,120 then practice dribbling at a different time without worrying about shooting or 16 00:00:55,120 --> 00:00:57,210 passing or what their teammates are doing. 17 00:00:58,340 --> 00:01:00,800 A Unit Test is like one of these drills and 18 00:01:00,800 --> 00:01:04,460 we can run unit tests constantly during our development process 19 00:01:04,460 --> 00:01:07,300 to ensure that everything is working every time we make a change. 20 00:01:08,980 --> 00:01:11,790 But being good at each single thing isn't enough to be 21 00:01:11,790 --> 00:01:13,750 a really good basketball player. 22 00:01:13,750 --> 00:01:16,670 They also have to be able to do them all together. 23 00:01:16,670 --> 00:01:19,370 In addition to practicing each individual basketball skill, 24 00:01:19,370 --> 00:01:21,920 players practice drills as a team. 25 00:01:21,920 --> 00:01:24,520 They need to make sure that they can dribble, pass, and 26 00:01:24,520 --> 00:01:29,050 shoot just as well when there are other people doing their part around them. 27 00:01:29,050 --> 00:01:31,620 And that they can do them all together in the correct sequence. 28 00:01:33,000 --> 00:01:36,660 In programming this kind of testing is called Integration Testing. 29 00:01:36,660 --> 00:01:41,130 You use integration tests when you add new code to preexisting code 30 00:01:41,130 --> 00:01:45,820 to make sure that not only do all of the pieces work individually as expected, but 31 00:01:45,820 --> 00:01:48,580 also that they run together correctly without breaking. 32 00:01:49,620 --> 00:01:53,650 Product managers or people who run open-source projects might also run 33 00:01:53,650 --> 00:01:58,450 integration tests whenever others write code to contribute to their projects. 34 00:01:58,450 --> 00:02:02,360 To make sure that the code others write doesn't break their existing project 35 00:02:02,360 --> 00:02:03,920 that's useful. 36 00:02:03,920 --> 00:02:07,380 On a basketball team it's not enough that your skills are up to par. 37 00:02:07,380 --> 00:02:09,930 And that you work well together as a team. 38 00:02:09,930 --> 00:02:12,450 You also have to play actual games. 39 00:02:12,450 --> 00:02:16,020 Live games are very different even from practice games, 40 00:02:16,020 --> 00:02:18,250 we play basketball on different courts. 41 00:02:18,250 --> 00:02:22,550 With different crowds and against teams with different strategies. 42 00:02:22,550 --> 00:02:27,640 So being a good basketball team requires a lot of team experience in this context. 43 00:02:29,380 --> 00:02:33,000 In software, this kind of testing is called End-To-End Testing. 44 00:02:33,000 --> 00:02:34,570 We fire up the application and 45 00:02:34,570 --> 00:02:38,590 run it from start to finish for all the user stories we can think of. 46 00:02:38,590 --> 00:02:41,840 This ensures that the program is ready to go live. 47 00:02:41,840 --> 00:02:46,010 And that the special details of deployment don't screw up the stuff that we 48 00:02:46,010 --> 00:02:49,940 carefully tested on our local machines with Unit Test and integration tests. 49 00:02:51,150 --> 00:02:53,680 We conduct end to end test very occasionally. 50 00:02:53,680 --> 00:02:56,690 Maybe only a few times during a product's life cycle. 51 00:02:56,690 --> 00:02:59,200 As a very time consuming and expensive. 52 00:02:59,200 --> 00:03:03,070 You might conduct some or all of these kind of tests where you work or 53 00:03:03,070 --> 00:03:04,750 in your personal projects. 54 00:03:04,750 --> 00:03:08,490 We'll focus on Unit Testing in this course because that's what you'll spend most of 55 00:03:08,490 --> 00:03:10,000 the time writing. 56 00:03:10,000 --> 00:03:13,070 Unit Tests actually help us write better code and 57 00:03:13,070 --> 00:03:15,600 grow as developers as soon as we start using them.