How To Install TestNG In Eclipse: Step By Step Guide
Tags: eclipse, selenium, testing, javascript
Published: 2020-08-06 09:12:29

As you already know, TestNG or Test Next Generation is one of the most frequently used [automation testing frameworks in Java](https://www.lambdatest.com/blog/top-5-java-test-frameworks-for-automation-in-2019/?utm_source=devto&utm_medium=organic&utm_campaign=nov28_kj&utm_term=kj&utm_content=blog). Inspired by JUnit and NUnit, Cedric Beust created TestNG with the idea of covering almost all types of testing models, be it functional or end-to-end. The annotations, functionalities, usability, features, and ease-of-use make TestNG a very popular choice of framework. Using [TestNG Annotations](https://www.lambdatest.com/blog/complete-guide-on-testng-annotations-for-selenium-webdriver/?utm_source=devto&utm_medium=organic&utm_campaign=nov28_kj&utm_term=kj&utm_content=blog) for Selenium completely depends on your business requirements. Listed below are some of the major benefits of using [TestNG for Selenium automation testing](https://www.lambdatest.com/selenium-automation-testing-with-testng?utm_source=devto&utm_medium=organic&utm_campaign=nov28_kj&utm_term=kj&utm_content=blog)–

* Reporting feature provides a detailed XML report of every successful, failed or skipped test.

* [Parallel testing](https://www.lambdatest.com/blog/what-is-parallel-testing-and-why-to-adopt-it/?utm_source=devto&utm_medium=organic&utm_campaign=nov28_kj&utm_term=kj&utm_content=blog) assists testers in running multiple test cases with the added benefit of CI/CD integration.

* Annotations feature allows developers to handle exceptions and understand the code easily.

* Test cases can be grouped together or prioritized easily.

* Flexible runtime configuration.

In this article, you will learn how to install TestNG in Eclipse and set it up in your system to start building a framework for your test project. Starting off with the installation of the TestNG plugin for Eclipse.

TestNG is based on Java and you need to install it in case you haven’t already. Now to begin with the installation of TestNG plugin for Eclipse, you need to launch Eclipse IDE and then follow these steps.

**Step #1:** Once Eclipse is launched, click on **Help** and then **Eclipse Marketplace**.

![](https://cdn-images-1.medium.com/max/2000/0*rGuYKgiqBtO4P8EK.png)

**Step #2:** A new window would open up, wherein you need to type “TestNG” in the Find text box and click on the Go button.

![](https://cdn-images-1.medium.com/max/2000/0*T5de1XtmZ6TFEytY.png)

**Step #3:** You will now see the search results with TestNG for Eclipse at the top. All you need to do now is click on the Install button next to it.

![](https://cdn-images-1.medium.com/max/2000/0*YRPoHy9BDB5RqwIK.png)

{% youtube 90F7dePW1vo %}

**Step #4:** Resolving of features might take up a few minutes after which you need to verify that the **checkbox for TestNG is checked** and click on the **Confirm** button.

![](https://cdn-images-1.medium.com/max/2000/0*S54JbSWFbUkFBJlT.png)

**Step #5:** Select “ **Keep my installation the same** ” option and again click on the **Confirm** button.

![](https://cdn-images-1.medium.com/max/2000/0*1g1onKI3jWqw193g.png)

**Step #6:** Accept the license and click on the **Finish** button.

![](https://cdn-images-1.medium.com/max/2000/0*zZsDyqPZCIGeGHuc.png)

**Note:** For the change to be effective, you will have to restart Eclipse and you will now be able to see TestNG installed by right-clicking on any project and seeing TestNG in the menu options.

![](https://cdn-images-1.medium.com/max/2000/0*2E8XZnJkIFwqaPae.png)

Did you see how easy this process was?

![](https://cdn-images-1.medium.com/max/2000/0*ZdrKfsRXU1uWmbSm.gif)

***Check out the article on [emulator vs simulator](https://www.lambdatest.com/blog/emulator-vs-simulator-vs-real-device/?utm_source=devto&utm_medium=organic&utm_campaign=nov28_kj&utm_term=kj&utm_content=blog) vs real device differences, the learning of which can help you select the right mobile testing solution for your business.***

## Can’t Find TestNG Plugin In The Eclipse Marketplace? Do This

In some versions of Eclipse, you might not find the **TestNG plugin** in the **Eclipse marketplace**. You can still install TestNG in Eclipse.

**Step 1:** Go to Eclipse help and click on the button to “ **Install New Software** ”.

![](https://cdn-images-1.medium.com/max/2000/0*nLPnkgvV7Mgm3rYg.png)

**Step 2:** Click the **Add** button and type “ **TestNG** ” as name and “[http://dl.bintray.com/testng-team/testng-eclipse-release/”](http://dl.bintray.com/testng-team/testng-eclipse-release/%E2%80%9D) as a path.

![](https://cdn-images-1.medium.com/max/2000/0*O-aiXt_aOIggguo9.png)

**Step 3:** Once you add the Path, you will notice a TestNG entry under the **name**. You then need to select that and click on **Next** to install TestNG in Eclipse. Accept the license agreement and hit the **Finish** button.

![](https://cdn-images-1.medium.com/max/2000/0*vHE2NpX9XaK3i8Xt.png)

It is greyed out in this image because I already have it installed. Don’t worry though, it will work for you perfectly. 🙂

With TestNG certification, you can challenge your skills in performing automated testing with TestNG and take your career to the next level.

Here’s a short glimpse of the TestNG certification from LambdaTest:

{% youtube dzXX2hJhuCY %}

***Perform manual or automated cross browser testing on 3000+ browsers online. Deploy and scale faster with the most powerful cross [browser testing](https://www.lambdatest.com/?utm_source=devto&utm_medium=organic&utm_campaign=nov28_kj&utm_term=kj&utm_content=webpage) tool online.***

## Don’t Want To Install TestNG With Eclipse? Use JAR File

If you do not want to install TestNG Eclipse or TestNG with IntelliJ, there is another way you can add TestNG to your project. It is by downloading the JAR file and then manually adding it to the build path of the project where you want to use it. Although we would definitely recommend installing the TestNG plugin for Eclipse. It is preferable to install the TestNG plugin for Eclipse rather than manually adding it to the build path as you will have to manually add it to every project. On the other hand, if it is installed in Eclipse you won’t have to go about configuring the build path again and again.

Let us quickly see the steps you would need to follow to –

1- You can download the TestNG lib file from [here](https://dl.bintray.com/testng-team/testng-eclipse-release/zipped/).

2- Once the zipped file is downloaded, copy it to a location of your choice. I have added it at below path in my system-

![](https://cdn-images-1.medium.com/max/2000/0*CzVPem_3ZYth6Iv7.png)

3- Now , open Eclipse and click on Help in the menu bar and click on Install New Software.

4- Click on Add and give name as TestNG and the path where you stored the zip file in the location field and click on OK.

![](https://cdn-images-1.medium.com/max/2000/0*5b1pb4hilHEunPQS.png)

5- Select TestNG and click on Next.

![](https://cdn-images-1.medium.com/max/2000/0*7M-OTQ1jh3vPzE5x.png)

6- Just click on Next if you get any Remediation or Install Details page. Accept the license and click on Finish.

![](https://cdn-images-1.medium.com/max/2000/0*AGlg5wa8IX5qabCe.png)

7- Restart your Eclipse.

8- Once done you need to add the library to the project build path. Right click on your project and go to Build path and in the new pop-up window click on Add Library.

![](https://cdn-images-1.medium.com/max/2000/0*grEARJGIZKkbOfIl.png)

9- You will see TestNG as an option in the new window, just select it and click on Next.

![](https://cdn-images-1.medium.com/max/2000/0*tx9GFbYQkNEUyge8.png)

10- Once done you will now see the testNG library under your project structure.

![](https://cdn-images-1.medium.com/max/2000/0*qZpx7NIdVI5fo6Tv.png)

11- You can now check if TestNG is ready to be used in your project by simply writing any annotation tag, like @Test in your script. You will see that on hovering on the tag, you get options to import the TestNG package.

![](https://cdn-images-1.medium.com/max/2000/0*2eAU940tvjXlP7_V.png)

And there you go you can see TestNG being configured in your system and all ready to use.

After installing TestNG Eclipse, we might need to convert some of the projects that we created as a regular java project to a TestNG project. Let me quickly brief you about how to do that.

***Need a great solution for testing [Safari browser for Windows](https://www.lambdatest.com/safari-browser-for-windows?utm_source=devto&utm_medium=organic&utm_campaign=nov28_kj&utm_term=kj&utm_content=webpage)? Forget about emulators or simulators — use real online browsers. Try LambdaTest for free!***

![](https://cdn-images-1.medium.com/max/2000/0*O5exT7SMlXk2_Pxk.png)

## Setting Up TestNG Eclipse Tests From Your Existing Java Projects

**Step #1:** Converting your existing tests into TestNG tests is a very easy process. Just open Eclipse and right-click on the project you need to convert to TestNG.

![](https://cdn-images-1.medium.com/max/2000/0*y5g0Qn4Odw7JFwLH.png)

**Step #2:** Select and click on Convert to TestNG. You will see a refactoring window popping up with the testng.xml details. For now, keep the things as it is and click on Finish. We will discuss testng.xml in detail in further posts. For now, let us see that our Java project is converted into TestNG and a testng.xml is created.

![](https://cdn-images-1.medium.com/max/2000/0*BeVYubnohIZk-BeB.png)

![](https://cdn-images-1.medium.com/max/2000/0*cwMdSjMeYDmwsQpa.png)

Now you can run the test classes under the project as TestNG tests.

![](https://cdn-images-1.medium.com/max/2000/0*P7AArBTALvjlTGUZ.png)

Now that we are done with the installation and set up of the [TestNG plugin for Eclipse](https://www.lambdatest.com/blog/how-to-install-testng-in-eclipse-step-by-step-guide/?utm_source=dev&utm_medium=Blog&utm_campaign=Kritika-6082020&utm_term=Kritika), we will further talk out about creating our first TestNG project and executing the same in our next post. We will be using Eclipse throughout the TestNG series, although it is completely up to you to run TestNG in Eclipse or any other IDE to write and run your test cases.

Now you can run your [first TestNG Selenium script](https://www.lambdatest.com/blog/a-complete-guide-for-your-first-testng-automation-script/).🙂