1 00:00:02,120 --> 00:00:08,700 What is testing? As I said, testing does not mean that we test our application manually, 2 00:00:08,720 --> 00:00:12,470 we obviously do that and we should do that. With testing here, 3 00:00:12,470 --> 00:00:15,430 I mean that we write automated tests. 4 00:00:15,590 --> 00:00:19,070 So what we typically do is we build an application, 5 00:00:19,280 --> 00:00:24,050 then of course we test it manually in the browser and then we ship it to a server, 6 00:00:24,170 --> 00:00:31,390 now there's one extra step we can add in any development workflow and that is that we don't just ship 7 00:00:31,390 --> 00:00:36,680 the app after testing it manually but that we also have automated tests. 8 00:00:36,680 --> 00:00:43,100 Now these are tests which run automatically, we write them and then each test tests a tiny fraction of 9 00:00:43,100 --> 00:00:44,120 our application, 10 00:00:44,180 --> 00:00:46,160 that's a so-called unit test, 11 00:00:46,160 --> 00:00:48,560 it tests a unit of our app. 12 00:00:48,570 --> 00:00:53,110 The idea behind such tests is that since we define these tests, 13 00:00:53,150 --> 00:01:00,170 if we change anything in our application and that breaks our app or breaks a component in our app then 14 00:01:00,170 --> 00:01:06,680 the respective test will fail and hence we might get a warning about a potential error we introduced 15 00:01:06,920 --> 00:01:12,230 before we even have to find it by manually testing the browser. In more complex applications, 16 00:01:12,230 --> 00:01:17,950 this is especially important since there, it's way easier to break something without quickly noticing 17 00:01:17,950 --> 00:01:22,050 it. There also is a different way of thinking about testing, 18 00:01:22,220 --> 00:01:28,940 instead of adding it in the end of the build workflow, there also is this idea of test driven development 19 00:01:28,970 --> 00:01:35,810 which you might have heard about, test driven development imports the tests first, there you write the 20 00:01:35,810 --> 00:01:38,530 tests before you write any application code 21 00:01:38,690 --> 00:01:44,720 and therefore all the tests will of course fail initially but then you add the application code and 22 00:01:44,720 --> 00:01:47,360 the test should pass step by step. 23 00:01:47,600 --> 00:01:49,010 That's not the concept 24 00:01:49,040 --> 00:01:50,240 I will show you here, 25 00:01:50,330 --> 00:01:53,540 this is no complete testing course, not at all 26 00:01:53,550 --> 00:01:58,700 instead I want to show you how to write these unit tests and you can of course then build up on this 27 00:01:58,700 --> 00:02:02,480 knowledge to use it in whichever way you want to use it. 28 00:02:02,480 --> 00:02:07,880 This however is the core idea of what testing is and why would we test? 29 00:02:07,880 --> 00:02:10,470 Well that is exactly what I already mentioned, 30 00:02:10,550 --> 00:02:16,160 we might have an application and there, we might have a component which does a couple of things as suggested 31 00:02:16,160 --> 00:02:20,140 here on the left and in the first draft we created for the component, 32 00:02:20,330 --> 00:02:23,970 it may pay us all the tests we defined for this given component 33 00:02:24,080 --> 00:02:28,190 so we wrote test for a given component and they pass. 34 00:02:28,190 --> 00:02:34,760 Now when we change something in this application or we add a new feature and that affects this component 35 00:02:35,000 --> 00:02:41,270 and we change something in that component for that reason then we still might have some passing tests 36 00:02:41,540 --> 00:02:43,990 but maybe some of our tests then fail 37 00:02:44,090 --> 00:02:50,510 and that's exactly showing us then where we need to look into our code and potentially fix or adjust it 38 00:02:50,930 --> 00:02:55,580 or fix or adjust our test to the changed requirements, either of the two, 39 00:02:55,640 --> 00:02:57,790 but at least we have to take a look at that 40 00:02:57,800 --> 00:03:01,930 so that's the idea behind testing. Now to be able to test, 41 00:03:01,970 --> 00:03:04,040 we need some testing tools. 42 00:03:04,040 --> 00:03:06,700 Let's take a closer look at these in the next lecture.