Setting up TestNG with Eclipse

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.

Comments 59

  • Thank you Seetaram, this was very useful to me.

    John

  • 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?

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

  • 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();
    }

    }

    • 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.

  • Thank you very much Seetaram.

  • Hi seetaram,

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

  • 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.

  • Thanks a lot. Easy steps to follow ….

  • 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..

  • Your help is appreciable

  • Hi seetaram , I tried installin

    An error occurred while collecting items to be installed

  • 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?

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

  • 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.

  • 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.

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

  • Excellent tutorial! thanks so much 🙂

  • Thanks. It helped me

  • Thanks Seetaram. It was very helpful.

  • wonderful sir
    keep up the good work

  • Thanks lot for this post . it is really helpful .

  • Very easy to understand.

  • Very useful and precise information

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

  • Great post I have my TestNG options back, delighted!

  • Thank You Sir…

  • 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 !!

  • Very useful information shared with world. Thank you very much

  • 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.

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

  • 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

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

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

  • Thanks a log…….

  • Thank you for the screen shots in detail..

  • This was very helpful. Thank you

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

    only s/w upadte option is there!!

  • 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.

  • 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?

  • Thanxx a lot,for the screen shots

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

  • 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

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

  • 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

  • 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.

  • 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?

  • 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!

  • 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)”

  • HI,

    I have installed testng but i am unable to see the testng under prefaces. Kindly help.

    • Now you can easily download and install TestNG from the eclipse marketplace. Once it is installed, create a project and a TestNG class. Right click on the TestNG class then you can see TestNG option available there

  • Hello,
    I am facing below error. Please help me to get out of it.

    [RemoteTestNG] detected TestNG version 6.9.10
    org.testng.TestNGException:
    Cannot find class in classpath: application.whatsApp
    at org.testng.xml.XmlClass.loadClass(XmlClass.java:81)
    at org.testng.xml.XmlClass.init(XmlClass.java:73)
    at org.testng.xml.XmlClass.(XmlClass.java:59)
    at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:556)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at org.testng.xml.XMLParser.parse(XMLParser.java:39)
    at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:16)
    at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:9)
    at org.testng.xml.Parser.parse(Parser.java:172)
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:305)
    at org.testng.remote.AbstractRemoteTestNG.initialize(AbstractRemoteTestNG.java:136)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:97)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.