1 00:00:00,000 --> 00:00:02,110 [No Audio] 2 00:00:02,110 --> 00:00:03,404 Let's create a test for this now then. 3 00:00:03,404 --> 00:00:06,920 So if I do shift command T, Create New Test. 4 00:00:06,920 --> 00:00:09,646 It's a UserLookupServiceTest and we'll 5 00:00:09,646 --> 00:00:12,458 have two sub methods here to create these 6 00:00:12,458 --> 00:00:14,758 test methods to test RegularUsers. 7 00:00:14,758 --> 00:00:17,326 AdminUsers get functionality of those respectively. 8 00:00:17,326 --> 00:00:20,826 So let's do OK, we've got our two Tests ready to go. 9 00:00:20,826 --> 00:00:23,456 So if we run this now just to make sure everything is 10 00:00:23,456 --> 00:00:26,872 set up okay, I can see we've got our two Tests. 11 00:00:26,872 --> 00:00:29,278 It still says that they're passed 12 00:00:29,278 --> 00:00:31,486 2 of 2 tests, one milliseconds. 13 00:00:31,486 --> 00:00:33,066 Everything's good. 14 00:00:33,066 --> 00:00:35,384 Let's write a test for this. Now 15 00:00:35,384 --> 00:00:37,148 whenever you're writing a unit test, always 16 00:00:37,148 --> 00:00:38,780 reflect back and look at the actual 17 00:00:38,780 --> 00:00:40,246 production code that you're testing. 18 00:00:40,246 --> 00:00:42,545 So you can do this by shift command T 19 00:00:42,545 --> 00:00:45,644 to go back to the corresponding production class. 20 00:00:45,644 --> 00:00:47,396 So command shift T will toggle between the 21 00:00:47,396 --> 00:00:49,940 production class you're testing and the actual class, 22 00:00:49,940 --> 00:00:51,644 which is the test class itself. 23 00:00:51,644 --> 00:00:53,722 So here we can go to production 24 00:00:53,722 --> 00:00:55,966 code, UserLookupService again, command shift 25 00:00:55,966 --> 00:00:57,482 T, you can go back to a test. 26 00:00:57,482 --> 00:01:00,320 So anyway, let's go shift command T back 27 00:01:00,320 --> 00:01:03,296 to the production code, UserLookupService 28 00:01:03,296 --> 00:01:05,206 and that would generate the test methods. 29 00:01:05,206 --> 00:01:06,355 We can move on. 30 00:01:06,355 --> 00:01:08,283 But I wanted to show you that to show you just 31 00:01:08,283 --> 00:01:10,215 how easy it is to toggle between the production class 32 00:01:10,215 --> 00:01:12,699 and the test class that's testing it because you'll 33 00:01:12,699 --> 00:01:14,732 find yourself frequently wanting to toggle between 34 00:01:14,732 --> 00:01:17,416 the two classes to either code up your test while 35 00:01:17,416 --> 00:01:19,616 referencing the production code is testing or even 36 00:01:19,616 --> 00:01:21,316 fix bugs in the production code 37 00:01:21,316 --> 00:01:24,074 as the test you're writing reveal defects in it. 38 00:01:24,074 --> 00:01:26,700 So, yeah, a useful trick to having your toolbox.