Sunday, January 2, 2011

Installing JUnit

Installing JUnit


1. JUnit is available at http://www.junit.org/. Go ahead and click the "Download JUnit" link shown in the following figure.

Figure: Downlond Link for JUnit

2. For the purpose of this tutorial, download junit-4.8.1.zip file into C drive. Unzip the junit-<version-number>.zip file into the root of your C drive (C:\). This creates a folder called C:\\junit<version-number>. To keep the tutorial simple, go ahead and rename the C:\Junitx.x folder to C:\Junit.

Figure: JUnit Folder
3. Now you have extracted JUnit, you need to add Junit.jar to your classpath. This enables the Java compiler to resolve where and what JUnit is.

In Windows,
  • Right click on "My Computer", select "Properties"
  • In "System Properties" form, click on "Advanced" tab
  • Click on "Environment Variable"
  • Double-click CLASSPATH and then enter the new value Ex: C:\JUnit\junit.4.81.jar
  • If you already have a setting in your CLASSPATH, make sure that you append the junit path by separating the new path with a semicolon.
Figure: Setting your CLASSPATH in Windows
 That's it. Now you are ready to execute your junit test cases.

<<Previous Next>>

No comments:

Post a Comment