1 00:00:06,480 --> 00:00:09,840 - In this section, we're going to see how to test classes. 2 00:00:09,840 --> 00:00:12,600 And we're also going to see how to mock classes as well. 3 00:00:12,600 --> 00:00:13,770 So if you have a look in the folder, 4 00:00:13,770 --> 00:00:16,263 Mocking Classes AutoMocks. 5 00:00:16,263 --> 00:00:17,160 If you have a look at the code in there 6 00:00:17,160 --> 00:00:18,750 you find we have two classes, 7 00:00:18,750 --> 00:00:21,810 we have a low-level class, RestClient 8 00:00:21,810 --> 00:00:25,500 and it invokes rest service methods on the web server. 9 00:00:25,500 --> 00:00:28,680 And then we have a higher-level class, ProductManager. 10 00:00:28,680 --> 00:00:31,380 ProductManager has higher-level methods 11 00:00:31,380 --> 00:00:34,500 like get stock count and get stock value. 12 00:00:34,500 --> 00:00:37,560 When I call methods in ProductManager it will invoke methods 13 00:00:37,560 --> 00:00:39,930 on RestClient underneath the surface. 14 00:00:39,930 --> 00:00:42,870 So let's take a quick look at those classes first. 15 00:00:42,870 --> 00:00:46,710 So this is the folder to go into, Mocking Classes-AutoMocks. 16 00:00:46,710 --> 00:00:48,810 If you open that up in the code editor, 17 00:00:48,810 --> 00:00:50,430 here we have the code. 18 00:00:50,430 --> 00:00:52,560 So first of all, my RestClient class 19 00:00:52,560 --> 00:00:55,050 it has various low-level methods, but first of all, 20 00:00:55,050 --> 00:00:58,200 it has a "constructor" the URL of the rest service 21 00:00:58,200 --> 00:01:00,300 that it's gonna call, and then it has methods 22 00:01:00,300 --> 00:01:03,630 to delete an item on the on the rest service, 23 00:01:03,630 --> 00:01:05,970 to update the product with new data, 24 00:01:05,970 --> 00:01:08,640 to get all products and to get one product. 25 00:01:08,640 --> 00:01:10,680 These are quite low-level methods. 26 00:01:10,680 --> 00:01:13,620 And what I'm gonna do is I want to mock these methods. 27 00:01:13,620 --> 00:01:16,593 When I'm testing my ProductManager class, 28 00:01:17,460 --> 00:01:20,220 it makes use of RestClient. 29 00:01:20,220 --> 00:01:22,890 When I call methods on my ProductManager, 30 00:01:22,890 --> 00:01:26,580 I wanna test these methods, but I want to blank off 31 00:01:26,580 --> 00:01:29,070 how it interacts with the low-level object. 32 00:01:29,070 --> 00:01:33,060 When you do unit testing, you're testing one class at a time 33 00:01:33,060 --> 00:01:35,910 and you want to mock how it interacts with other objects 34 00:01:35,910 --> 00:01:38,400 because that would just interfere with our tests. 35 00:01:38,400 --> 00:01:39,870 So that's what we're going to do. 36 00:01:39,870 --> 00:01:43,200 We're gonna see how I can define mocks for the RestClient 37 00:01:43,200 --> 00:01:46,920 API so whenever I call a high-level method, 38 00:01:46,920 --> 00:01:50,280 it'll call a mock version of the RestClient method. 39 00:01:50,280 --> 00:01:52,890 If I call this function in my test, 40 00:01:52,890 --> 00:01:55,865 it'll call a mock version of that method. 41 00:01:55,865 --> 00:01:57,690 If I call this function in my test, 42 00:01:57,690 --> 00:01:59,820 it'll call a mock version of that method. 43 00:01:59,820 --> 00:02:01,140 So I'm gonna basically mock, 44 00:02:01,140 --> 00:02:04,200 I want to mock everything in the RestClient module 45 00:02:04,200 --> 00:02:06,630 so that it doesn't complicate my tests. 46 00:02:06,630 --> 00:02:08,730 Okay, so we've seen the ProductManager class 47 00:02:08,730 --> 00:02:11,730 it uses the RestClient class. 48 00:02:11,730 --> 00:02:14,040 I'm going to unit test ProductManager, 49 00:02:14,040 --> 00:02:17,040 therefore I'm going to mock the RestClient 50 00:02:17,040 --> 00:02:20,670 so that it doesn't interfere with my high-level tests. 51 00:02:20,670 --> 00:02:21,930 So have a think about this, 52 00:02:21,930 --> 00:02:24,960 how can you mock an entire class? 53 00:02:24,960 --> 00:02:28,050 Well, the easiest way to do it is via automatic mocking. 54 00:02:28,050 --> 00:02:29,790 We've seen this before actually. 55 00:02:29,790 --> 00:02:32,250 If you think about it the RestClient class 56 00:02:32,250 --> 00:02:34,620 defines a bunch of methods. 57 00:02:34,620 --> 00:02:38,880 If I go back into RestClient, it defines a constructor 58 00:02:38,880 --> 00:02:39,990 and a bunch of methods here. 59 00:02:39,990 --> 00:02:43,980 So there were various functions defined in this module 60 00:02:43,980 --> 00:02:47,220 and we've already seen how to define mocks 61 00:02:47,220 --> 00:02:48,750 for an entire module. 62 00:02:48,750 --> 00:02:51,600 What you do is you call jest.mock 63 00:02:51,600 --> 00:02:53,400 and you specify the name of the file, 64 00:02:53,400 --> 00:02:56,010 or the name of the module that you want to mock. 65 00:02:56,010 --> 00:02:58,770 And if that file defines a class 66 00:02:58,770 --> 00:03:00,660 then when you mock this module 67 00:03:00,660 --> 00:03:04,350 it'll define a mock version of every method in that class. 68 00:03:04,350 --> 00:03:06,840 It'll define a mock version of the constructor 69 00:03:06,840 --> 00:03:08,070 and a mock version for all 70 00:03:08,070 --> 00:03:10,500 the methods in the class automatically. 71 00:03:10,500 --> 00:03:13,050 So just by mocking the file, 72 00:03:13,050 --> 00:03:15,570 I'll automatically generate a mock version 73 00:03:15,570 --> 00:03:18,120 of the construction, the delete update, 74 00:03:18,120 --> 00:03:20,370 get all, and get methods. 75 00:03:20,370 --> 00:03:24,993 Okay, so I can then use those mocks in my unit test. 76 00:03:26,430 --> 00:03:30,330 So this is a simple example, first of all. 77 00:03:30,330 --> 00:03:33,450 First of all, I've imported the RestClient module 78 00:03:33,450 --> 00:03:36,180 and I've mocked it, so I've justified mock versions 79 00:03:36,180 --> 00:03:38,400 of the constructor for RestClient 80 00:03:38,400 --> 00:03:41,943 and the update, delete, get, get all method. 81 00:03:44,040 --> 00:03:45,390 So basically I have a mock version 82 00:03:45,390 --> 00:03:47,700 of the constructor, for example. 83 00:03:47,700 --> 00:03:52,000 When I create a RestClient object it'll call the constructor 84 00:03:52,860 --> 00:03:57,390 but it basically calls the mock version of the constructor. 85 00:03:57,390 --> 00:04:01,890 So if I draw that here, the mock version of the constuctor 86 00:04:01,890 --> 00:04:06,420 has just been called, and basically that mock constructor 87 00:04:06,420 --> 00:04:11,420 is identified here, "rc.RestClient" is the mock constructor, 88 00:04:12,627 --> 00:04:13,960 "rc.RestClient." 89 00:04:15,237 --> 00:04:20,070 And as we're gonna show in a moment, the mock object 90 00:04:20,070 --> 00:04:23,040 you can verify that it has been called once. 91 00:04:23,040 --> 00:04:25,440 When I created a RestClient object 92 00:04:25,440 --> 00:04:27,090 you can go to the mock object 93 00:04:27,090 --> 00:04:30,390 and say, "The mock constructor should have been called once" 94 00:04:30,390 --> 00:04:32,820 because I've created a RestClient 95 00:04:32,820 --> 00:04:36,120 and furthermore, a mock object, if you remember this 96 00:04:36,120 --> 00:04:39,870 from one of the earlier lessons, when you have a mock object 97 00:04:39,870 --> 00:04:42,300 the mock object has a property called mock. 98 00:04:42,300 --> 00:04:44,340 Okay, so I can draw that here. 99 00:04:44,340 --> 00:04:46,473 It has a property called mock. 100 00:04:47,580 --> 00:04:49,920 And what that does, it gives you information, 101 00:04:49,920 --> 00:04:51,870 a whole load of information actually 102 00:04:51,870 --> 00:04:54,900 about how that mock object has been used. 103 00:04:54,900 --> 00:04:58,020 So this mock property gives me a whole load 104 00:04:58,020 --> 00:05:00,390 of metadata, a whole load of information 105 00:05:00,390 --> 00:05:02,610 about how that constructor was invoked. 106 00:05:02,610 --> 00:05:05,527 So if it's a constructor, for example it can say, 107 00:05:05,527 --> 00:05:08,490 "The mock object, it has an instances property." 108 00:05:08,490 --> 00:05:13,110 It has an instances property, which tracks all the objects, 109 00:05:13,110 --> 00:05:16,140 all the RestClient objects that you've created 110 00:05:16,140 --> 00:05:18,558 but I've only created one RestClient object here. 111 00:05:18,558 --> 00:05:22,500 So this instance is zero should point to 112 00:05:22,500 --> 00:05:25,890 the RestClient instance that I created. 113 00:05:25,890 --> 00:05:27,900 I created the object here. 114 00:05:27,900 --> 00:05:30,330 If I go to the mock function for the constructor, 115 00:05:30,330 --> 00:05:33,180 go to the mock property, that's this object, 116 00:05:33,180 --> 00:05:37,050 this mock object here has an instances property. 117 00:05:37,050 --> 00:05:40,650 It tells me about all the instances that are being created. 118 00:05:40,650 --> 00:05:44,100 Okay, so instances zero, it's an array, basically. 119 00:05:44,100 --> 00:05:46,020 If I'd created multiple instances 120 00:05:46,020 --> 00:05:47,160 then it would kind of look like this. 121 00:05:47,160 --> 00:05:50,940 There would be multiple instances in an array like that, 122 00:05:50,940 --> 00:05:52,560 but we've only created one instance 123 00:05:52,560 --> 00:05:55,320 so it should just be element zero. 124 00:05:55,320 --> 00:05:59,670 Element zero in my list of interfaces should be exist. 125 00:05:59,670 --> 00:06:01,680 It shouldn't be undefined. 126 00:06:01,680 --> 00:06:06,630 So just to summarize that then, the mock constructor 127 00:06:06,630 --> 00:06:08,550 should have been called once. 128 00:06:08,550 --> 00:06:11,850 The mock constructor, because it's a mock function, 129 00:06:11,850 --> 00:06:15,060 it has a mock property and the mock property gives me 130 00:06:15,060 --> 00:06:18,360 information about how that function has been called. 131 00:06:18,360 --> 00:06:20,767 In the case of a constructor we can say, 132 00:06:20,767 --> 00:06:23,730 "what instances have you accrued?" 133 00:06:23,730 --> 00:06:27,210 Well, there should have been one instance, that instance, 134 00:06:27,210 --> 00:06:30,363 so that instance should not be identified, it should exist. 135 00:06:31,590 --> 00:06:33,300 So there's a lot of information available there. 136 00:06:33,300 --> 00:06:35,760 I could run that test and it would work out. 137 00:06:35,760 --> 00:06:38,040 Oh, don't forget to clear all mocks. 138 00:06:38,040 --> 00:06:40,650 When you have mock objects, at the end of each test 139 00:06:40,650 --> 00:06:44,100 you are to erase that mock history 140 00:06:44,100 --> 00:06:47,340 that you've been accumulating like the list of instances, 141 00:06:47,340 --> 00:06:50,370 clear that out at the end of each test so that 142 00:06:50,370 --> 00:06:53,070 for the next test you start with a blank canvas again. 143 00:06:53,910 --> 00:06:57,660 So I run that test and it works. 144 00:06:57,660 --> 00:07:00,560 You can run it yourself and you'll find that it does work. 145 00:07:01,590 --> 00:07:03,420 We're gonna be a little bit more ambitious now. 146 00:07:03,420 --> 00:07:06,660 Instead of just creating a RestClient object directly 147 00:07:06,660 --> 00:07:08,520 what I'm gonna do now is create it indirectly. 148 00:07:08,520 --> 00:07:11,520 Have a look at this code, I create a ProductManager object. 149 00:07:11,520 --> 00:07:14,520 Now, if you remember, when you create a ProductManager, 150 00:07:14,520 --> 00:07:17,430 internally it also creates a RestClient. 151 00:07:17,430 --> 00:07:18,263 Remember that? 152 00:07:18,263 --> 00:07:19,230 Let me show you the code. 153 00:07:19,230 --> 00:07:21,690 Here's my ProductManager. 154 00:07:21,690 --> 00:07:23,610 When I create a ProductManager, 155 00:07:23,610 --> 00:07:26,700 it creates a RestClient indirectly. 156 00:07:26,700 --> 00:07:29,730 So think about what's going on here. 157 00:07:29,730 --> 00:07:32,130 I've created a ProductManager. 158 00:07:32,130 --> 00:07:34,980 Okay, so here's my ProductManager object. 159 00:07:34,980 --> 00:07:39,633 It's a cloud shape, it has a pointer, 160 00:07:41,040 --> 00:07:44,160 it basically called the RestClient constructor. 161 00:07:44,160 --> 00:07:49,140 So basically this is the mock constructor, if you like, 162 00:07:49,140 --> 00:07:52,410 for RestClient, it called the mock constructor 163 00:07:52,410 --> 00:07:54,930 because I've mocked everything in the RestClient class. 164 00:07:54,930 --> 00:07:56,280 When I call the constructor, 165 00:07:56,280 --> 00:08:00,090 it calls the mock constructor for RestClient. 166 00:08:00,090 --> 00:08:02,880 Okay, so we should be able to verify that the mock 167 00:08:02,880 --> 00:08:06,810 constructor has been called by the ProductManager. 168 00:08:06,810 --> 00:08:08,430 And we should be able to verify 169 00:08:08,430 --> 00:08:12,100 that this mock constructor, which has a mock property 170 00:08:13,380 --> 00:08:16,830 which I'll draw there, that's this in here, 171 00:08:16,830 --> 00:08:20,790 that gives me kind of metadata about how many times 172 00:08:20,790 --> 00:08:23,317 the mock object was called, and it should say, 173 00:08:23,317 --> 00:08:25,620 "Well, these are the instances that have been created." 174 00:08:25,620 --> 00:08:29,580 It has an instances property, same as just now instances. 175 00:08:29,580 --> 00:08:33,330 And that basically points to all the RestClient objects 176 00:08:33,330 --> 00:08:34,953 that I've created as an array. 177 00:08:35,850 --> 00:08:38,370 Well, I've created one ProductManager 178 00:08:38,370 --> 00:08:42,270 and that one ProductManager created one RestClient. 179 00:08:42,270 --> 00:08:45,660 So that should indicate that the RestClient constructor, 180 00:08:45,660 --> 00:08:49,320 one instance of RestClient has been created. 181 00:08:49,320 --> 00:08:52,293 So that should just be element zero. 182 00:08:53,550 --> 00:08:55,680 Okay, so just to reiterate then, 183 00:08:55,680 --> 00:08:58,980 the ProductManager created the RestClient. 184 00:08:58,980 --> 00:09:02,190 The RestClient mock says, "oh, I've been called." 185 00:09:02,190 --> 00:09:05,760 And it gives me via mock property on the mock function, 186 00:09:05,760 --> 00:09:07,860 the mock property will give me information 187 00:09:07,860 --> 00:09:11,605 about all the instances that have been created, 188 00:09:11,605 --> 00:09:15,590 that it has been created like so. 189 00:09:15,590 --> 00:09:18,480 So to run that test, that's the name of the test. 190 00:09:18,480 --> 00:09:19,387 If you look at the code, 191 00:09:19,387 --> 00:09:22,350 "Call the RestClient constructor indirectly" 192 00:09:22,350 --> 00:09:26,820 and if you run that test, like so, it works. 193 00:09:26,820 --> 00:09:28,920 I've got one more example to show you. 194 00:09:28,920 --> 00:09:32,220 This is a bit more tricky. 195 00:09:32,220 --> 00:09:34,620 What I'm gonna do is I'm gonna call this method 196 00:09:34,620 --> 00:09:38,460 on ProductManager, I'm going to remove a bunch of products 197 00:09:38,460 --> 00:09:41,793 and I'm gonna pass in a commerce separated list of IDs. 198 00:09:42,870 --> 00:09:44,700 When I call this function 199 00:09:44,700 --> 00:09:47,763 it should call the delete function on my RestClient. 200 00:09:48,960 --> 00:09:51,870 If I pass in three numbers here, it should call 201 00:09:51,870 --> 00:09:55,137 the delete function three times on my RestClient 202 00:09:56,250 --> 00:09:59,883 to delete each product with that ID. 203 00:10:00,720 --> 00:10:02,853 So let's see how to test that. 204 00:10:03,840 --> 00:10:06,900 When we call remove products, how can we verify, 205 00:10:06,900 --> 00:10:09,180 I mean, I can see the code here, but how would I verify 206 00:10:09,180 --> 00:10:12,000 from a testing point of view that if I remove products 207 00:10:12,000 --> 00:10:15,270 with three numbers here it calls the delete function 208 00:10:15,270 --> 00:10:17,430 three times on my RestClient interface? 209 00:10:17,430 --> 00:10:20,070 You would want to be able to test that. 210 00:10:20,070 --> 00:10:23,460 So this code here, this is quite involved, 211 00:10:23,460 --> 00:10:24,840 so I'm gonna draw a picture 212 00:10:24,840 --> 00:10:26,940 and then I'll kind of explain what's going on. 213 00:10:26,940 --> 00:10:31,680 So, first of all, just looking at this line 214 00:10:31,680 --> 00:10:33,480 that creates a ProductManager object, 215 00:10:33,480 --> 00:10:35,640 which is still a cloud shape. 216 00:10:35,640 --> 00:10:39,420 And as we've seen, it creates a RestClient 217 00:10:39,420 --> 00:10:41,370 or to be more specific, 218 00:10:41,370 --> 00:10:44,413 it calls the mock constructor for RestClient, think so. 219 00:10:47,160 --> 00:10:51,660 And we can verify that the mock constructor 220 00:10:51,660 --> 00:10:53,043 has been called once. 221 00:10:54,600 --> 00:10:57,030 Oh, and by the way, then I call 222 00:10:57,030 --> 00:10:59,370 the "remove products" method on ProductManager, 223 00:10:59,370 --> 00:11:01,833 so I call the "remove product" method on there. 224 00:11:02,744 --> 00:11:05,520 And what it should do is it should call delete 225 00:11:05,520 --> 00:11:08,460 three times to delete product one, two and three. 226 00:11:08,460 --> 00:11:09,810 It should call the delete function 227 00:11:09,810 --> 00:11:12,570 three times on the RestClient. 228 00:11:12,570 --> 00:11:16,920 So this code here verifies that it's done it properly. 229 00:11:16,920 --> 00:11:18,480 I'm gonna explain what's going on. 230 00:11:18,480 --> 00:11:22,200 So first of all, this is my mock constructor 231 00:11:22,200 --> 00:11:24,210 and the mock constructor has a mock property, 232 00:11:24,210 --> 00:11:27,933 we've seen that a few times now, it has a mock property. 233 00:11:29,400 --> 00:11:32,880 Okay, and that gives me the mock object, 234 00:11:32,880 --> 00:11:35,250 information about my RestClient. 235 00:11:35,250 --> 00:11:38,460 And it has an instances field, as we know, 236 00:11:38,460 --> 00:11:39,870 and that instances field, 237 00:11:39,870 --> 00:11:43,950 it gives me back all the instances of RestClient. 238 00:11:43,950 --> 00:11:46,500 I've only got one instance of RestClient, 239 00:11:46,500 --> 00:11:48,660 so I'm gonna draw that here. 240 00:11:48,660 --> 00:11:51,123 That's the instance of RestClient that was created 241 00:11:51,123 --> 00:11:53,220 when I created the ProductManager. 242 00:11:53,220 --> 00:11:55,683 It basically created the RestClient object here. 243 00:11:56,640 --> 00:12:01,640 Okay, so this variable here is my RestClient object. 244 00:12:02,850 --> 00:12:07,500 Now, this here basically represents your object, 245 00:12:07,500 --> 00:12:09,270 your RestClient object 246 00:12:09,270 --> 00:12:12,840 and the RestClient object had a bunch of methods. 247 00:12:12,840 --> 00:12:14,710 For example, it had a delete method 248 00:12:15,840 --> 00:12:20,840 and it had a get-all method and it had a get-one method. 249 00:12:21,990 --> 00:12:25,140 And it had an update method, I think it was called. 250 00:12:25,140 --> 00:12:27,607 Like that, so what you can do is you can actually say 251 00:12:27,607 --> 00:12:31,380 "go to my RestClient object," which is this thing here. 252 00:12:31,380 --> 00:12:34,440 And basically "give me a pointer to the delete method." 253 00:12:34,440 --> 00:12:38,370 This here is the mock object 254 00:12:38,370 --> 00:12:41,580 that represents the delete method for my bank account. 255 00:12:41,580 --> 00:12:44,070 So effectively this is the mock 256 00:12:44,070 --> 00:12:46,353 delete method on my RestClient. 257 00:12:47,220 --> 00:12:50,850 And just like any mock functions, it has a mock property. 258 00:12:50,850 --> 00:12:53,943 So this here has a mock property. 259 00:12:55,560 --> 00:12:58,140 And that mock property gives me information 260 00:12:58,140 --> 00:13:00,390 about how that delete method was called 261 00:13:00,390 --> 00:13:03,030 upon this RestClient object. 262 00:13:03,030 --> 00:13:06,450 So I can say, "go to this mock object 263 00:13:06,450 --> 00:13:09,240 tell me information about your calls." 264 00:13:09,240 --> 00:13:12,630 Basically this here tells me how many times 265 00:13:12,630 --> 00:13:14,640 was the delete method called? 266 00:13:14,640 --> 00:13:17,640 There should have been three calls. 267 00:13:17,640 --> 00:13:20,010 My delete method has mock information. 268 00:13:20,010 --> 00:13:22,980 It tells me how many times the mock function was called. 269 00:13:22,980 --> 00:13:26,283 The delete function should have been called three times. 270 00:13:27,120 --> 00:13:29,010 And you can get information about each call. 271 00:13:29,010 --> 00:13:31,680 It has complete history of how methods 272 00:13:31,680 --> 00:13:33,300 were invoked on the object. 273 00:13:33,300 --> 00:13:35,820 We're basically saying for the RestClient, 274 00:13:35,820 --> 00:13:39,570 which had a delete method, for the first call 275 00:13:39,570 --> 00:13:42,783 the zero parameter should have been product 101. 276 00:13:43,950 --> 00:13:48,810 For the next call, the zero parameter should have been 102. 277 00:13:48,810 --> 00:13:52,173 For the next call to the delete method, for the second call, 278 00:13:53,310 --> 00:13:54,840 effectively the third call, 279 00:13:54,840 --> 00:13:57,510 then the first parameter should have been 103. 280 00:13:57,510 --> 00:14:01,170 What I'm checking here is that when I called remove products 281 00:14:01,170 --> 00:14:06,120 it called delete once, twice, three times on the RestClient 282 00:14:06,120 --> 00:14:10,203 passing in the values, 101, 102, and 103. 283 00:14:11,340 --> 00:14:13,350 So that's quite complicated, you might wanna run 284 00:14:13,350 --> 00:14:15,570 that through again just to convince yourself. 285 00:14:15,570 --> 00:14:18,630 I just summarize what I've just been describing. 286 00:14:18,630 --> 00:14:21,840 First of all, create the ProductManager object 287 00:14:21,840 --> 00:14:23,460 which creates a RestClient. 288 00:14:23,460 --> 00:14:26,493 Verify that the RestClient constructor was invoked. 289 00:14:27,360 --> 00:14:30,630 Call the method that we're trying to test 290 00:14:30,630 --> 00:14:32,523 and then check how it worked. 291 00:14:33,570 --> 00:14:36,960 From the constructor give me the mock information, 292 00:14:36,960 --> 00:14:39,723 that'll give me back the RestClient object. 293 00:14:40,560 --> 00:14:42,960 On that RestClient object, give me information 294 00:14:42,960 --> 00:14:45,063 about the delete method on that object. 295 00:14:46,020 --> 00:14:50,610 And then see if that delete method was called three times. 296 00:14:50,610 --> 00:14:55,140 See if the first call passed in the first parameter of 101. 297 00:14:55,140 --> 00:14:57,600 And if the second call, call number one 298 00:14:57,600 --> 00:15:00,060 passed in the parameter of 102 299 00:15:00,060 --> 00:15:03,750 and the final call passed in the parameter of 103. 300 00:15:03,750 --> 00:15:08,220 So it takes a bit of effort but the advantage is 301 00:15:08,220 --> 00:15:12,240 that the end of the day now you can verify that your code 302 00:15:12,240 --> 00:15:17,160 interacts properly with the object that sits behind it. 303 00:15:17,160 --> 00:15:21,663 So all we need to do now is run the test and relax.