1 00:00:00,000 --> 00:00:02,230 [No Audio] 2 00:00:02,230 --> 00:00:03,848 In this video we're going to create a 3 00:00:03,848 --> 00:00:05,996 quick project which uses JUnit using the 4 00:00:05,996 --> 00:00:08,324 Maven Quickstart Archetype in IntelliJ IDEA. 5 00:00:08,324 --> 00:00:09,632 And in this way we'll have a nice 6 00:00:09,632 --> 00:00:11,360 project which we can use to play around 7 00:00:11,360 --> 00:00:13,868 with, and demonstrate JUnit in future videos. 8 00:00:13,868 --> 00:00:17,917 So let's get started. So first off, just go into IDEA. 9 00:00:17,917 --> 00:00:20,984 So I'm using IntelliJ IDEA as the IDE for this demo. 10 00:00:20,984 --> 00:00:22,628 You might be using Eclipse or another 11 00:00:22,628 --> 00:00:24,332 IDE such as NetBeans or something. 12 00:00:24,332 --> 00:00:26,060 That's fine, it doesn't really matter. 13 00:00:26,060 --> 00:00:27,766 We just want to get a feel for how JUnit 14 00:00:27,766 --> 00:00:30,282 works and get a bit of a refresher together. 15 00:00:30,282 --> 00:00:32,396 So first thing I'm going to do is create a 16 00:00:32,396 --> 00:00:35,412 project which we can use to demonstrate JUnit in. 17 00:00:35,412 --> 00:00:38,096 So I go to Create New Project here and 18 00:00:38,096 --> 00:00:40,064 I'm going to choose to Create a Maven project. 19 00:00:40,064 --> 00:00:41,986 And if I just hit next here then what's 20 00:00:41,986 --> 00:00:43,484 going to happen is it's going to use the 21 00:00:43,484 --> 00:00:46,085 Maven quickstart archetype to create the project. 22 00:00:46,085 --> 00:00:48,320 Which means it will just create a basic Hello 23 00:00:48,320 --> 00:00:49,844 World kind of project for us which we can 24 00:00:49,844 --> 00:00:51,536 use to walk through JUnit with. 25 00:00:51,536 --> 00:00:54,980 So just hit next here, the GroupId. 26 00:00:54,980 --> 00:00:59,430 [No Audio] 27 00:00:59,430 --> 00:01:01,296 Just put a nice simple GroupId 28 00:01:01,296 --> 00:01:04,428 and for ArtifactId, have the nice and simple one. 29 00:01:04,428 --> 00:01:06,361 We're just going to use myapp. 30 00:01:06,361 --> 00:01:09,946 So now if I hit next, then we can see 31 00:01:09,948 --> 00:01:12,026 it's going to create the Project, myapp and it's 32 00:01:12,026 --> 00:01:14,052 going to create it on my Desktop and that's fine. 33 00:01:14,052 --> 00:01:15,351 So if I hit finish here, 34 00:01:15,351 --> 00:01:19,294 [No Audio] 35 00:01:19,294 --> 00:01:21,376 you can see it very quickly created the project on 36 00:01:21,376 --> 00:01:23,848 my desktop and then immediately opened it. 37 00:01:23,848 --> 00:01:25,324 So I'm just going to first of all, before 38 00:01:25,324 --> 00:01:27,222 I do anything I'm going to just select this option 39 00:01:27,222 --> 00:01:29,934 down here which says Enable Auto-Import and what 40 00:01:29,934 --> 00:01:33,354 that does that basically ensures that the dependencies 41 00:01:33,354 --> 00:01:35,553 which I include in the pom.xml file 42 00:01:35,553 --> 00:01:36,954 those dependencies are immediately 43 00:01:36,954 --> 00:01:39,522 reflected in IntelliJ IDEA’s class path. 44 00:01:39,522 --> 00:01:42,010 So what I mean by that, is if I open up myapp 45 00:01:42,010 --> 00:01:44,704 then you see this External Libraries section here. 46 00:01:44,704 --> 00:01:46,540 If I open that, you'll see there's nothing 47 00:01:46,540 --> 00:01:49,155 in here currently apart from the JDK. However 48 00:01:49,155 --> 00:01:52,092 to include JUnit when I add it to the pom.xml file 49 00:01:52,092 --> 00:01:53,961 here by adding a dependency which I'll do in a 50 00:01:53,961 --> 00:01:56,634 second, you'll see that this External Library section 51 00:01:56,634 --> 00:01:59,191 here will then include the JUnit library and also the 52 00:01:59,191 --> 00:02:01,732 Hamcrest library too which JUnit happens to bring in 53 00:02:01,732 --> 00:02:03,748 as a transitive dependency, in other words as a 54 00:02:03,748 --> 00:02:06,215 dependency which JUnit itself needs to be able to 55 00:02:06,215 --> 00:02:10,514 operate. So if I just hit command n to generate 56 00:02:10,514 --> 00:02:15,664 dependency just like that here, and type junit, I go 57 00:02:15,664 --> 00:02:19,554 down to this one here and this is actually showing 58 00:02:19,554 --> 00:02:22,242 me a filtered view of all the mail and repositories 59 00:02:22,242 --> 00:02:24,894 that I've chosen to index on my install of IntelliJ 60 00:02:24,894 --> 00:02:26,893 idea at the various versions that those repositories 61 00:02:26,893 --> 00:02:29,176 have. And I am happy with version 4.12. 62 00:02:29,176 --> 00:02:30,276 So if I just click Add, 63 00:02:30,276 --> 00:02:32,284 [No Audio] 64 00:02:32,284 --> 00:02:34,767 you can see here it's added that dependency and it's 65 00:02:34,767 --> 00:02:36,467 also immediately added it here as well 66 00:02:36,467 --> 00:02:39,366 so it's added junit itself and also the hamcrest 67 00:02:39,378 --> 00:02:42,482 library which junit depends on, so just put a bit 68 00:02:42,496 --> 00:02:45,727 of a space here keep things nice and tidy. 69 00:02:45,727 --> 00:02:47,642 So at this stage we're going to have a project which 70 00:02:47,656 --> 00:02:49,742 is set up to use junit and we'll see how 71 00:02:49,756 --> 00:02:51,935 we can do that in the next videos.