Setting up TestNG with Eclipse

by seetaram on January 9, 2012

This post will explain about installation of TestNG plug-in with Eclipse (Indigo)

There is no need to download any Jar file or exe file for installation.  We need to just utilize the “Install New Software” option available in the Eclipse.

Steps for installation:

1. Click Help –> Install New Software

TestNG-HelpMenu

TestNG-SelectSite

TestNG-Add

2. Type “http://beust.com/eclipse” in the “Work with” edit box and click ‘Add’ button

3. In the ‘Name’ column we can see “TestNG” –> Select this and click ‘Next’ button

TestNG-Install

4.  Click Next and click on the radio button “I accept the terms of the license agreement”

5. Click ‘Next’ button

6. Click ‘Finish’

TestNG-Install wizard

This will install the TestNG plug-in for Eclipse

After the installation, it will ask for restart of Eclipse.  Then restart the Eclipse.

Once the Eclipse is restarted, we can see the TestNG icons & menu items as in the below figures.

TestNG-RunAs

TestNG-NewSelectWizard

TestNG-RunAsTest

It is very much clearly explained how to setup the TestNG with eclipse.  The screenshots make it easy to understand the setting up of TestNG. I hope this will help people who are eager to start using TestNG for their unit testing as well as UI Test Automation with Selenium.

{ 55 comments… read them below or add one }

John January 24, 2012 at 12:31 pm

Thank you Seetaram, this was very useful to me.

John

Reply

jeff April 1, 2012 at 3:37 am

hi was just doing this but now, there are multiple testng versions when I put in the url and. Also the icon doesn’t match. This new plugin is giving me issues. I had the old plugin before and it works, but now it won’t let me install the old one. what can i do?

Reply

Nandan May 14, 2012 at 1:28 pm

seetaram your blog has been a handbook for all Selenium details! thanks a ton

Reply

Chaithra June 8, 2012 at 6:28 am

am getting error on running TestNG class file
error: “java.lang.NoSuchMethodError: org.openqa.selenium.remote.DesiredCapabilities.safari()Lorg/openqa/selenium/remote/DesiredCapabilities;”

code is attached here,

package pacakge1;

import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestBase;
import com.thoughtworks.selenium.Selenium;

public class NewTest extends SeleneseTestBase{

public Selenium selenium;
public SeleniumServer seleniumserver;

RemoteControlConfiguration rcc = new RemoteControlConfiguration();
public static final String url = “http://192.168.5.151/FirstSource/FirstSource/LoginPage.aspx”;
public String GetCurPageURL;

@BeforeClass
public void setupBeforeClass() throws Exception {

selenium = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://”);
seleniumserver = new SeleniumServer(rcc);
seleniumserver.boot();
seleniumserver.start();
selenium.start();
selenium.setSpeed(“1000”);
selenium.windowMaximize();
selenium.open(url);
}

@Test
public void Login() throws Exception {
selenium.waitForPageToLoad(“30000”);
selenium.type(“txtName”, “AdminVLE”);
selenium.type(“txtPwd”, “AdminVLE”);
selenium.click(“SignIn”);
}

@AfterClass
public void teardownAfterClass() throws Exception{
selenium.stop();
seleniumserver.stop();
}

}

Reply

seetaram June 9, 2012 at 6:10 am

Hello Chaithra,

I have tried your code, but not getting any exception. Can you try putting a break point and do step by step debug? Find out from where the exception is coming.

Reply

Chintan June 9, 2012 at 5:47 pm

Thank you very much Seetaram.

Reply

Chaithra June 11, 2012 at 6:23 am

Hi seetaram,

The problem raised at the selenium server start up. So this comes in @BeforeClass annotation.

Reply

Chaithra June 11, 2012 at 6:46 am

Hi Seetaram,

One of my other query is, how to provide the dynamic Page url for each @Test method in TestNg class file?

Suppose… Once class file has 3 @ test methods. So how can i pass Dynamic page url for the 2nd and 3 rd @Test method to find the page objects?

Thanks
Chaithra.

Reply

narla June 13, 2012 at 4:24 pm

Thanks a lot. Easy steps to follow ….

Reply

sri June 14, 2012 at 6:44 am

I am getting following error while installing TestNG framework on eClipse-Helios:
Cannot complete the install because one or more required items could not be found.
Software currently installed: Shared profile 1.0.0.1339651876009 (SharedProfile_epp.package.jee 1.0.0.1339651876009)
Missing requirement: Shared profile 1.0.0.1339651876009 (SharedProfile_epp.package.jee 1.0.0.1339651876009) requires ‘SharedProfile_epp.package.jee [1.0.0.1339650838047]’ but it could not be found
could you please help me in resolving this issue..

Reply

raju dantuluri June 26, 2012 at 1:34 pm

Your help is appreciable

Reply

vikas July 2, 2012 at 4:22 pm

Hi seetaram , I tried installin

An error occurred while collecting items to be installed

Reply

Melody July 18, 2012 at 2:27 pm

Hello seetaram,

I cannot pick the testing.xml to set up the TestNG Suite executuion. The “browse” button does not browse on the “Suite” option. Can you assist?

Reply

seetaram July 29, 2012 at 12:42 pm

Hi Melody,

I need more info..can you elaborate please..

Reply

mangesh September 17, 2012 at 7:16 am

seetaram you have done a very good job, seetaram you are great…

Reply

Saleem Darbar September 25, 2012 at 4:25 pm

Hi ,
I followed all the steps to configure the TestNg,but
when I am trying to run the Testcase through TestNg it’s not working.Can you tell me how to resolve this issue.

Reply

Sanjay September 28, 2012 at 6:38 am

Hi,

i am installing the TestNG using Ecilpce software but in setp2 its gives the error “can not find http://beust.com/eclipse/” please suggest me solution or clarify me where i am wrong.

Reply

dolly May 9, 2013 at 8:47 am

avoid using quotation marks.
use http://beust.com/eclipse/ . Then u will find “TestNG” in the “Name” column

Reply

Arjun January 10, 2013 at 4:27 am

Thank you so much for this valuable post. It made things real easy.

Reply

MrBCut January 27, 2013 at 7:33 pm

Excellent tutorial! thanks so much 🙂

Reply

Balu February 10, 2013 at 10:55 am

Thanks. It helped me

Reply

Chirag Desai February 12, 2013 at 9:50 am

Thanks Seetaram. It was very helpful.

Reply

madesh March 6, 2013 at 5:30 am

wonderful sir
keep up the good work

Reply

sanjit paul April 23, 2013 at 5:41 pm

Thanks lot for this post . it is really helpful .

Reply

dolly May 9, 2013 at 8:52 am

Very easy to understand.

Reply

tunga June 10, 2013 at 6:22 pm

Very useful and precise information

Reply

kiran July 23, 2013 at 4:40 pm

thanks

Reply

Gnaneshwar July 31, 2013 at 1:26 am

Hi
I installed the test NG but i couldn’t see the test NG after the installation
Your help is highly appreciated
Regards
Gnaneshwar

Reply

Isaac August 12, 2013 at 3:04 pm

Great post I have my TestNG options back, delighted!

Reply

Pravin August 12, 2013 at 3:24 pm

Thank You Sir…

Reply

Bharad October 19, 2013 at 12:50 am

After so much of time exploring “how to install testNG” in google , none of the blogs helpful for me . But this is one of the very best spoonfeed steps here . I really appreciate for your best efforts in providing these steps . It is so useful . Thanks a lot !!

Reply

Ilakkuvan November 15, 2013 at 11:20 am

Very useful information shared with world. Thank you very much

Reply

Hasitha December 4, 2013 at 7:58 am

Very useful information you share with us. Sir, do you have any document about Annotations used in Test-NG? Because i am new to automation stuff.

Reply

seetaram December 6, 2013 at 6:07 am
mahesh December 27, 2013 at 11:12 am

i am learning selenium course.
in my institute they are explaining webdriver and testing frameworks only,is it necessary to learn selenium RC.

Reply

seetaram January 10, 2014 at 6:57 am

I dont think that is needed now

Reply

mahesh December 27, 2013 at 11:15 am

hi,
i downloaded poi api,but every time only four files are coming .can u explain way to download poi api to work with excel sheet

Reply

seetaram January 10, 2014 at 7:02 am

POI is a folder containing many files, add the the jar files to the classpath which are appropriate for the APIs you are using.

Reply

Ramesh Reddy January 9, 2014 at 9:05 am

Thank you very much…this helped me to install testNG easily.

Reply

Taruna May 24, 2014 at 5:58 am

Hi!
I am getting File transfer error while installing testNG in Galileo & Helio.

Reply

mogannagowda June 13, 2014 at 8:37 am

Thanks a log…….

Reply

vissu August 20, 2014 at 10:03 am

Thank you for the screen shots in detail..

Reply

Sylvia Ombuya September 29, 2014 at 9:42 pm

This was very helpful. Thank you

Reply

harish October 8, 2014 at 8:18 am

In my eclipse(europa) Help –> Install New Software option is not there…how to install testNG then??

only s/w upadte option is there!!

Reply

shanthi January 3, 2015 at 12:43 pm

Hi,
while installing the testNG iam getting error as: ” unable to read reposity at http:/eclipse/content.xml ”

Could you please suggest me how to resolve this .

Thanks a lot in advance.

Reply

Hema March 10, 2015 at 5:59 am

I am a newbie in automation. I have a very basic doubt when I create a java project (which also contains javascript ) I write a testNG file. How is the testing.xml created? or should I create testing.xml separately?

Reply

prateek bhati March 13, 2015 at 5:32 am

Thanxx a lot,for the screen shots

Reply

Sowndarya June 23, 2015 at 12:52 pm

I installed the test NG but i couldn’t see the test NG after the installation.
Thanks in advance

Reply

Rajesh July 7, 2015 at 6:01 am

Hi,

I am a beginner and I want to use TestNG, when I proceed with the steps mentioned and clicked on “Add”, it shows there are no items available.

I use JDK 8.0.

Thanks in Advance,

Rajesh Gokul.S

Reply

Saurav August 3, 2015 at 11:24 am

It worked for me very well on an Ubuntu machine. 12.04LTS. Installed on Eclipse Juno 4.2

Reply

Sony September 2, 2015 at 8:32 am

Am new to selenium, after installing TestNG, while running testNg
An internal error occurred during: “Launching test_NG”. org.osgi.framework.Version.compareTo(Lorg/osgi/framework/Version;)I

Reply

mohit October 28, 2015 at 6:19 am

on installing testNG i am getting following error…

how can i solve it…..

An error occurred while collecting items to be installed
session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
Problems downloading artifact: osgi.bundle,org.testng.eclipse,6.9.9.201510270734.
MD5 hash is not as expected. Expected: 5e8dd350672caf82ef56d27865fb822e and found a715c20c11c2320b2656d1cb3c7d94a5.

Reply

shreya abrol February 11, 2016 at 7:18 am

I am a newbie in automation. I have a very basic doubt when I create a java project (which also contains javascript ) I write a testNG file. How is the testing.xml created? or should I create testing.xml separately?

Reply

children of sanchez June 4, 2016 at 10:55 am

you’re in reality a just right webmaster. The website loading velocity
is amazing. It kind of feels that you are doing any distinctive trick.
Furthermore, The contents are masterpiece. you’ve performed
a wonderful task in this topic!

Reply

Vishvanath Chougule June 22, 2016 at 4:31 pm

Getting below error while installing TestNG

“Cannot complete the install because one or more required items could not be found.
Software being installed: TestNG M2E Integration (Optional) 6.9.11.201604020423 (org.testng.eclipse.maven.feature.feature.group 6.9.11.201604020423)”

Reply

Leave a Comment

Previous post:

Next post:

Do you want to get updates on the recent articles written? Please subscribe to RSS feed or Email