Hiya folks! Bring out the testing ninja that is hiding within you as today we are going to set up the environment for JUnit framework.
Jumping right in:
Step 1:
Go to, http://junit.org/junit4/ and click on ‘Download and Install’ link.
Step 2:
The following points will make the process all the more easy to understand,
- You will be redirected to GitHub. Under ‘Plain-old JAR’, junit and hamcrest-core jars will be available.
- Clicking on ‘junit.jar’ will redirect you to a page with download links. Click on the latest version ‘jar’ link (v4.12 at the time of writing this post). It will be automatically downloaded to your system.
- Next, click on ‘hamcrest-core.jar’. Similar to the above point, click on the latest available ‘jar’ download link (v1.3 as of the day this post is taking its form).
- Both the required jars are thus downloaded to your system now.
Below is the image highlighting the steps,
Step 3:
Next job is to add these two jars to our project in eclipse IDE. The process is very similar to what we followed in the post, “9b. Setting up WebDriver (In Eclipse)”. Please refer that for step by step instructions along with screenshots.
- Open Eclipse IDE and navigate to the corresponding workspace.
- Right click on the project with Selenium set up -> Build Path -> Configure Build Path…
- Make sure Libraries tab is chosen. Click on ‘Add Library…’
- Select ‘user library’ -> Next -> click on ‘User Libraries…’
- Click on ‘New…’ and give a name to the library ‘JUnit4’ and Click ‘OK’
- In ‘User Libraries’ pop up window, make sure newly created Junit4 library is selected. Click on ‘Add external JARs…’
- Navigate to the path where the downloaded junit related jars are saved in your local system. Select both junit and hamcrest-core jars and click ‘Open’
Click OK and Finish buttons accordingly and the newly created JUnit4 library will be added to the project build path as shwon below,
With that, the environment for JUnit 4 is all set! In our next post let us write WebDriver tests in JUnit framework and execute them to see the results.
See you again in another post! Have a nice day!