1 00:00:00,000 --> 00:00:03,000 [No Audio] 2 00:00:03,010 --> 00:00:05,036 Before we get into the asserts, let's just run 3 00:00:05,036 --> 00:00:06,416 it and put a breakpoint here and make sure 4 00:00:06,416 --> 00:00:08,060 that we actually get some users back. 5 00:00:08,060 --> 00:00:09,250 Just testing this method. 6 00:00:09,250 --> 00:00:11,024 I could test all the methods, but I 7 00:00:11,024 --> 00:00:12,430 just want to test this method. 8 00:00:12,430 --> 00:00:13,960 I'd rather run this method. 9 00:00:13,960 --> 00:00:16,570 Sorry, I'll try again I'd rather Debug this method. 10 00:00:16,570 --> 00:00:19,317 So right click Debug. 11 00:00:19,317 --> 00:00:21,562 And then when we get to that breakpoint 12 00:00:21,562 --> 00:00:25,186 there at this point, we should see that. Yes, indeed. 13 00:00:25,186 --> 00:00:26,528 We've got the UserLookupService. 14 00:00:26,528 --> 00:00:28,904 We've got the userRepository, which is a mock. 15 00:00:28,904 --> 00:00:32,503 And here we have the user list, which is a full 16 00:00:32,503 --> 00:00:35,794 set of users, which was returned back from the mock. 17 00:00:35,794 --> 00:00:39,104 So that's our list of users we had. 18 00:00:39,104 --> 00:00:41,578 We can see here, we've got anne and 19 00:00:41,578 --> 00:00:43,856 donald, which are both REGULAR_USERS, and then 20 00:00:43,856 --> 00:00:48,020 we've got beebop, who is an ADMIN_USER. Yeah. 21 00:00:48,020 --> 00:00:49,712 And then we have the actual users themselves, 22 00:00:49,712 --> 00:00:51,596 which have been filtered through as they've been 23 00:00:51,596 --> 00:00:53,479 returned from the production method we actually 24 00:00:53,479 --> 00:00:54,945 invoked, which is this method here, this 25 00:00:54,945 --> 00:00:57,472 UserLookupService, getRegularUsers. 26 00:00:57,472 --> 00:00:59,238 So we can have a look in here. We can have a sneak 27 00:00:59,238 --> 00:01:01,397 peek. It's what I normally do when I'm writing 28 00:01:01,397 --> 00:01:02,660 tests as well. It can be nice. 29 00:01:02,660 --> 00:01:05,638 And we can see we've got REGULAR_USER, REGULAR_USER. 30 00:01:05,638 --> 00:01:07,063 They're both what we expect. 31 00:01:07,063 --> 00:01:09,872 So to me, at a first glance, just 32 00:01:09,872 --> 00:01:13,232 in debug mode, we've got enough data here 33 00:01:13,232 --> 00:01:16,402 to test the production code that we're invoking. 34 00:01:16,402 --> 00:01:19,078 The method we're testing. We've tested the method. 35 00:01:19,078 --> 00:01:24,140 And as a curious developer, I've set a breakpoint and 36 00:01:24,140 --> 00:01:26,302 I can see here that I'm getting back the 37 00:01:26,302 --> 00:01:27,968 data that I think I should get back. 38 00:01:27,968 --> 00:01:30,296 So at this point now, as a developer, I've kind 39 00:01:30,296 --> 00:01:32,696 of got confidence that the API seems to work at 40 00:01:32,696 --> 00:01:34,808 least for a happy path the way it's supposed to. 41 00:01:34,808 --> 00:01:36,757 So that's kind of nice. It's always nice to do that, 42 00:01:36,757 --> 00:01:39,408 to be honest, because rather than like churning out 43 00:01:39,408 --> 00:01:40,941 a ton of assertions or whatever 44 00:01:40,941 --> 00:01:42,358 it might be or writing out all of unit 45 00:01:42,358 --> 00:01:44,626 tests, first of all, give yourself that reward. 46 00:01:44,626 --> 00:01:45,836 Write a bit of production code. 47 00:01:45,836 --> 00:01:47,816 Write a little bit of test code to invoke it. 48 00:01:47,816 --> 00:01:49,628 Check it, getting back what you expect. 49 00:01:49,628 --> 00:01:51,514 And it gives you that little bit of bit of a buzz 50 00:01:51,514 --> 00:01:53,830 to you know, to move on because you're a little bit 51 00:01:53,830 --> 00:01:55,139 happier that you're getting closer to your 52 00:01:55,139 --> 00:01:57,422 own solution or to your end goal rather. 53 00:01:57,422 --> 00:02:00,381 If you happen to be writing tests but the same as you 54 00:02:00,381 --> 00:02:02,636 developing your production code, but always give 55 00:02:02,636 --> 00:02:04,931 yourself a little boost just to keep you motivated. 56 00:02:04,931 --> 00:02:06,016 [No Audio]