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“.
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).