9f. WebDriver – JUnit Environment Set-up

This entry is part 32 of 48 in the series Selenium

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.

Junit download link

Step 2:

The following points will make the process all the more easy to understand,

  1. You will be redirected to GitHub. Under ‘Plain-old JAR’, junit and hamcrest-core jars will be available.
  2. 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.
  3. 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).
  4. Both the required jars are thus downloaded to your system now.

Below is the image highlighting the steps,

Junit github download

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.

  1. Open Eclipse IDE and navigate to the corresponding workspace.
  2. Right click on the project with Selenium set up -> Build Path -> Configure Build Path…
  3. Make sure Libraries tab is chosen. Click on ‘Add Library…’
  4. Select ‘user library’ -> Next -> click on ‘User Libraries…’
  5. Click on ‘New…’ and give a name to the library ‘JUnit4’ and Click ‘OK’
  6. In ‘User Libraries’ pop up window, make sure newly created Junit4 library is selected. Click on ‘Add external JARs…’
  7. 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’

Junit user library

Click OK and Finish buttons accordingly and the newly created JUnit4 library will be added to the project build path as shwon below,

Junit jars added

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!

Series Navigation<< 9e. WebDriver – Code samples for launching other browsers9g. WebDriver – Running WebDriver tests in JUnit4 >>
By | 2017-07-14T22:07:24+00:00 December 12th, 2016|Selenium|0 Comments

About the Author:

Leave A Comment