Alvin Bunk

Alvin's Blog.

JUnit Tutorial

JUnit is a unit testing framework for testing Java applications. It’s been around for a long time and therefore is is widely used.

In order to use JUnit in Eclipse, you simply need to create a Java Project, create a package, add a class file, and then then add a “JUnit Test Case”. Let’s step through that.

First start up Eclipse. In these screen shots I’m using 32bit Eclipse Juno (because I’m also working with JBoss), however this shouldn’t matter much. By the way, if you haven’t used Eclipse IDE before, what are you waiting for?

Once Eclipse starts, select “File > New > Java Project“. The Dialog box “New Java Project” appears like the screenshot below. Set the project name to “JUnit Test Project“.

New Java Project

Click “Next >” to continue. We need to add a source folder called “test” where we will store all the JUnit files. Click the “Create new source folder” and enter a folder name of “test”, then click “Finish“. The dialog box will look like the image below (that is before you click Finish).

JUnit Folders


One thought on “JUnit Tutorial

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: