Adding Testng To Eclipse

How to integrate TestNG with eclipse and Write the first program in TestNG. We have to follow some basic steps to install the TestNG plugin in eclipse.

Install TestNG in Eclipse directly from the Eclipse Marketplace. All the new Eclipse IDE versions are. Second thing is now that you use Maven manage the project dependencies, you need to put the testng in your pom.xml, rather than adding local library Copy link Author.

There is two way to install TestNG in Eclipse.

Install Testng In Eclipse

  • Add TestNG plugin manually.
  • Download from the market place.

Install TestNG plugin Manually in the eclipse

  • Run Eclipse.
  • Go to “Help” in the top menu bar and click to “Install New Software” option.
  • Click to Add option.
  • Now, Enter Name = “TestNG” and Location = http://dl.bintray.com/testng-team/testng-eclipse-release/
  • Select the TestNG check.
  • Accept the license and start the installation.
Adding Testng To Eclipse

During this manual installation might be we get some error or it’s not installed properly. Then we can choose the second option to install TestNG from the market place.

Error: could not find http //beust.com/eclipse while installing testng

Now let’s see how to solve this error and Download TestNG from the market place of the eclipse.

Install TestNG from the eclipse market place

1) Open Eclipse.
2) Click to help in the top menu and navigate to “Eclipse Marketplace”.

Adding Testng To Eclipse Cloud

3) Find testNG and install it.

4) Confirm and accept the license conditions

5) Wait until it installs the testNG.

6) Restart eclipse and verify the TestNG under the windows > Show View > others and search for TestNG.

It will take some time to finish the installation process to please wait until its install properly. Now create a new Java project and start the automation.

Write an automation test case using TestNG.

Create a java project using maven in the eclipse and create a TestNG. Let’s follow some basic steps to run your first automation test case using TestNG.

Plugin

Step 1) Create a Simple Java or Maven Project in Eclipse.

Step 2) Create a TestNG class. In My Case, I create a class with the name “TestCase1” under the “Testcase” package.

Adding Testng To Eclipse

Step 3) Observe the autogenerated code in the class. Did you notice there is some error? Don’t worry we are just missing a jar file for TestNG.

Step 4) Add TestNG jar into the project.

Download Testng For Eclipse

If you are working with maven then open the “pom.xml”, Add the dependency for TestNG and save it. To find the latest version of TestNG just Google “Maven dependency for TestNG”.

If you are using a simple java project then you have to download TestNG jar and manually need to import it in the project library.

Step 5) Write the first TestNG Program.

Step 6) Run the TestNG class.

If you can see the output. It means your machine and eclipse is ready for automation with TestNG. Now in upcoming tutorials will cover all the step by step topics that comes under the testNG with examples.