[No Audio]
In this video we're going to create a
quick project which uses JUnit using the
Maven Quickstart Archetype in IntelliJ IDEA.
And in this way we'll have a nice
project which we can use to play around
with, and demonstrate JUnit in future videos.
So let's get started. So first off, just go into IDEA.
So I'm using IntelliJ IDEA as the IDE for this demo.
You might be using Eclipse or another
IDE such as NetBeans or something.
That's fine, it doesn't really matter.
We just want to get a feel for how JUnit
works and get a bit of a refresher together.
So first thing I'm going to do is create a
project which we can use to demonstrate JUnit in.
So I go to Create New Project here and
I'm going to choose to Create a Maven project.
And if I just hit next here then what's
going to happen is it's going to use the
Maven quickstart archetype to create the project.
Which means it will just create a basic Hello
World kind of project for us which we can
use to walk through JUnit with.
So just hit next here, the GroupId.
[No Audio]
Just put a nice simple GroupId
and for ArtifactId, have the nice and simple one.
We're just going to use myapp.
So now if I hit next, then we can see
it's going to create the Project, myapp and it's
going to create it on my Desktop and that's fine.
So if I hit finish here,
[No Audio]
you can see it very quickly created the project on
my desktop and then immediately opened it.
So I'm just going to first of all, before
I do anything I'm going to just select this option
down here which says Enable Auto-Import and what
that does that basically ensures that the dependencies
which I include in the pom.xml file
those dependencies are immediately
reflected in IntelliJ IDEA’s class path.
So what I mean by that, is if I open up myapp
then you see this External Libraries section here.
If I open that, you'll see there's nothing
in here currently apart from the JDK. However
to include JUnit when I add it to the pom.xml file
here by adding a dependency which I'll do in a
second, you'll see that this External Library section
here will then include the JUnit library and also the
Hamcrest library too which JUnit happens to bring in
as a transitive dependency, in other words as a
dependency which JUnit itself needs to be able to
operate. So if I just hit command n to generate
dependency just like that here, and type junit, I go
down to this one here and this is actually showing
me a filtered view of all the mail and repositories
that I've chosen to index on my install of IntelliJ
idea at the various versions that those repositories
have. And I am happy with version 4.12.
So if I just click Add,
[No Audio]
you can see here it's added that dependency and it's
also immediately added it here as well
so it's added junit itself and also the hamcrest
library which junit depends on, so just put a bit
of a space here keep things nice and tidy.
So at this stage we're going to have a project which
is set up to use junit and we'll see how
we can do that in the next videos.