Saturday, December 31, 2011

Start With JUnit

Important Points :
  • It is considered a best practice in testing, to separate the test case code from the application code. Typically the application code is in a source folder called src/ while the test code is in a source folder called tests/.
  • Below is the file structure for a JUnit Project ,example
Project Hierarchy
  • To run JUnit test cases the JUnit libraries must be on the classpath
  • The JUnit library is required to be on the project classpath to compile and run the JUnit test cases. If your JUnit library isn't set up correctly, there will be an warning message at the top of the Java Build Path window.
Steps for adding junit jar on the Build Path :
  1. Right click on the project and select Properties. In the left column select Java Build Path and select the Libraries tab.
  2. Select the Add Library... button to the right of the window. Select JUnit from the library list, and press the Next > button
  3. Use the drop down box to select the version of JUnit that you want to use for your project. 
OR
  1. Right click on the project and select Properties. In the left column select Java Build Path. To the right select the Libraries tab. Click the Add External JARs... button. You should start off in the Eclipse install directory, otherwise search through the file system until you find the Eclipse install directory.
  2. Under the Eclipse install directory select plugins/org.junit_XXX/junit.jar. Click OK.
OR
  1. Download junit.jar from www.junit.org. Add junit.jar to your lib/ directory in your project.
  2. Right click on the project and select Properties. In the left column select Java Build Path. To the right select the Libraries tab. Click the Add JARs... button. Select your project, and go down through the tree until you find junit.jar under the lib folder. Select junit.jar and Click OK.


No comments:

Post a Comment