Last updated on April 21st, 2020 at 09:03 pm
When you create some TestNG tests and you want to run that test as a TestNG test in Eclipse, by default you do not get any option for that. To run TestNG tests in Eclipse, we need TestNG Plugin for Eclipse.
Since IntelliJ comes bundled with TestNG plugin, you do not require to install explicitly in IntelliJ. Another point to note here that TestNG library and TestNG plugin both are two different things. TestNG library used to write TestNG tests while TestNG plugin required for eclipse to run TestNG tests.
We can install TestNG plugin in Eclipse in two ways:-
- Using Market Place
- Using Install New Software option
Using Eclipse Market Place Option:
Steps to be followed:
Steps 1: Navigate to Help-> Eclipse Marketplace.
You will see below screen.
Steps 2: Type “TestNG” in “Find” test box and click on “Search” icon. It will search and show you TestNG.
If TestNG is not installed, it will show you “Installed” else “Install”. Click on “Install” and it will be installed.
Steps 3: Click on “Confirm” button.
Steps 4: Click on radio button of “I accept the term of the licence agreement.” and click on “Finish” button.
Steps 5: You might get below warning message. Click on “Install anyways”.
Steps 6: Restart Eclipse.
You are done with the installation of TestNG Plugin in Eclipse now.
You may not find TestNG in Eclipse Market Place sometimes, then you can drag and drop from below URL to Eclipse Market Place.
Using Install New Software Option:
This is the best way to install TestNG plugin in Eclipse as in first way, many times you face problems like TestNG is not found in Eclipse Market Place.
When you download TestNG plugin in Eclipse using Eclipse Market Place, you will see an URL from where it will be downloaded. Same URL you can directly provide that URL in “Install New Software” option. Further steps are same as above way.
URL is as below:-
Recently URL was changed. So you should always check URL in official TestNG document here.
Type above URL in “Work With” text box. As soon as you type,it will start searching and will show “TestNG” in text area. Click on checkbox of TestNG and click on “Next” button. Since TestNG Eclipse Plugin 6.9.10, there is a new optional plug-in for M2E (Maven Eclipse Plugin) integration. It’s recommended to install it if your Java project(s) are managed by Maven.
You need to accept terms of Apache license agreement and restart eclipse to complete installation of TestNG plugin.
After installation, you will see Run as a TestNG Test for TestNG class as shown below :-
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.