Friday, June 18, 2010

Unit Testing

Using JUnit tests in Eclipse...

A unit test is a piece of code written by a developer that tests a specific functionality in the code which is tested. Unit tests can ensure that functionality is working and can be used to validate that this functionality still works after code changes.

Installation of JUnit Test

To make JUnit available in your Java project you have to add the JUnit library file to your JavaClasspath.

To do that

  • right click on the Project folder and go to Properties.
  • Under Properties go to the Java Build Path tab under which go to Libraries.
  • Now Do Add Linrary and then select JUnit then Next.
  • Now add JUnit tests version 3 or 4 as you want.
Prepration:

Create a new project . We want to create the unit tests in a separate folder. Create therefore a new source folder "test" via right mouse click on your project, select properties and choose the "Java Build Path". Select the tab source code.

No comments:

Post a Comment