Now that we have added tests and created a test suite, lets see if Eclipse can help us run our Junit tests. As we are already using Eclipse for developing our Unit tests, we can use the inbuilt Junit runner.

Step 1: Open Junit Perspective

  1. To open Junit runner you have to go to Window > Show View > Other.

Junit-2

  1. In the pop up window select Java. In the options under Java select Junit. and click OK

Junit-3

3. Baam, you will have Junit test runner in the left eclipse view explorer. You can relate from the below image.

Junit-9

Step 2: Run Configuration settings

  1. To run your tests you have to set run configurations in your project. Go to Package explorer and right click on your project. From the menu that comes up select Run As > Run Configurations. As shown in the image below

Junit-10

  1. Once you click on the Run Configurations, you will see a Run Configuration window. In the left pane of Configuration window right-click on the Junit option and select New.

Junit-11

  1. After clicking on New you will see a new configuration set up window. Now select 'Run all tests in the selected project' radio button and browse to the folder where all your unit tests are.

Junit-12

  1. Click on Apply and now Run your project. You will see that all tests are run and the result is displayed in the Junit runner.

Junit-13

Explore different options in Junit runner and you will find some really nice features.

JUnit Test Suite
JUnit Test Suite
Previous Article
Junit Test with Selenium WebDriver
Junit Test with Selenium WebDriver
Next Article
Virender Singh
I am Virender Singh, I have around 14 years of experience in the Technology domain.
Reviewers
Lakshay Sharma's Photo
Lakshay Sharma

Similar Articles

Feedback