1 00:00:00,000 --> 00:00:02,276 [No Audio] 2 00:00:02,276 --> 00:00:04,894 Now let's just see, what happens if we don't 3 00:00:04,894 --> 00:00:07,016 have both of those things in we'll see that 4 00:00:07,016 --> 00:00:09,166 Hamcrest gives you a really nice error message. 5 00:00:09,166 --> 00:00:11,674 [No Audio] 6 00:00:11,674 --> 00:00:14,432 So running now, we get this nice error message here. 7 00:00:14,432 --> 00:00:17,180 So this means it's expecting Iterable over, 8 00:00:17,180 --> 00:00:19,064 which basically just means a collection of. 9 00:00:19,064 --> 00:00:21,372 So it's expecting a collection of and then here 10 00:00:21,372 --> 00:00:23,437 it specifies the collection itself, and it uses 11 00:00:23,437 --> 00:00:25,736 this notation where the square brackets here, you can 12 00:00:25,736 --> 00:00:28,412 see a square bracket here, square bracket here. 13 00:00:28,412 --> 00:00:31,077 And anything inside that is the actual 14 00:00:31,077 --> 00:00:33,162 elements of a collection. So in other words, the 15 00:00:33,176 --> 00:00:35,193 square brackets means a collection. 16 00:00:35,193 --> 00:00:37,880 So it's expecting a collection of, 17 00:00:37,880 --> 00:00:39,884 and then inside we can 18 00:00:39,884 --> 00:00:42,333 see between these angle brackets. 19 00:00:42,333 --> 00:00:45,182 This is where it's specifying an object, 20 00:00:45,182 --> 00:00:47,974 actual object is expecting inside that collection. 21 00:00:47,974 --> 00:00:50,132 So the collection has square brackets, and then 22 00:00:50,132 --> 00:00:52,990 within that you'll have objects that it's expecting, 23 00:00:52,990 --> 00:00:54,094 which are elements of the collection. 24 00:00:54,094 --> 00:00:55,714 And those are in angle brackets. 25 00:00:55,714 --> 00:00:57,286 So here is it saying it's expecting 26 00:00:57,286 --> 00:01:00,152 a collection which just contains one thing. 27 00:01:00,152 --> 00:01:01,856 And that one thing is anne, as you can 28 00:01:01,856 --> 00:01:06,019 see here, but it's saying it's got something extra. 29 00:01:06,019 --> 00:01:08,468 And what it's got extra is another object. 30 00:01:08,468 --> 00:01:09,646 We can see it's just angle brackets. 31 00:01:09,646 --> 00:01:11,974 So it's going to an object, which is donald. 32 00:01:11,974 --> 00:01:14,756 It's saying I'm not expecting donald, you've just told 33 00:01:14,756 --> 00:01:17,746 me to expect an collection just containing anne. 34 00:01:17,746 --> 00:01:19,042 Instead I've got anne and donald. 35 00:01:19,042 --> 00:01:20,700 That's what that means there. 36 00:01:20,700 --> 00:01:22,466 So we just put that back in here 37 00:01:22,466 --> 00:01:24,590 [No Audio] 38 00:01:24,590 --> 00:01:27,911 to fix it up and re run. 39 00:01:27,911 --> 00:01:29,864 And that's fine. 40 00:01:29,864 --> 00:01:32,446 Now if it turns out we had a different password, 41 00:01:32,446 --> 00:01:35,097 [No Audio] 42 00:01:35,097 --> 00:01:39,735 for example, and then rerun, then again we get 43 00:01:39,735 --> 00:01:41,950 another nice error message, which is very readable. 44 00:01:41,950 --> 00:01:43,900 So this is a really good thing with Hamcrest 45 00:01:43,900 --> 00:01:46,786 over and above the JUnit assertions API. 46 00:01:46,786 --> 00:01:48,644 And that's the fact that the error messages you get 47 00:01:48,644 --> 00:01:50,616 back when you get assertion failures, they're very 48 00:01:50,616 --> 00:01:52,658 readable and they really tell you exactly what the 49 00:01:52,658 --> 00:01:56,075 issue is. So here it's saying, okay, we expect a 50 00:01:56,075 --> 00:01:59,100 collection of and now we're saying we've got two things 51 00:01:59,100 --> 00:02:00,183 we're expecting in there, 52 00:02:00,183 --> 00:02:02,066 [No Audio] 53 00:02:02,066 --> 00:02:03,033 and 54 00:02:03,033 --> 00:02:06,409 [No Audio] 55 00:02:06,409 --> 00:02:10,424 and donald with that specific password. 56 00:02:10,424 --> 00:02:13,416 But instead it's saying I've got a 57 00:02:13,416 --> 00:02:18,690 problem because donald, I've got donald here, 58 00:02:18,690 --> 00:02:20,378 which has a different password. 59 00:02:20,378 --> 00:02:22,000 No, it doesn't tell you 60 00:02:22,000 --> 00:02:23,822 the password is different explicitly. 61 00:02:23,822 --> 00:02:25,488 So you have to kind of eyeball this and see 62 00:02:25,488 --> 00:02:28,321 that this password bit here is different to this 63 00:02:28,321 --> 00:02:29,556 password. But here. 64 00:02:29,556 --> 00:02:30,912 But you get the idea it's still 65 00:02:30,912 --> 00:02:32,736 very readable and it's much better from 66 00:02:32,736 --> 00:02:35,320 JUnit and its existing assertion API. 67 00:02:35,320 --> 00:02:40,053 So let's fix that up again by reverting that rerun. 68 00:02:40,053 --> 00:02:43,319 Everything is fine. But now you know how to interpret 69 00:02:43,319 --> 00:02:46,100 Hamcrest assertion failures. So let's move on.