How can I add main class in eclipse cucumber project. I am running cucumber feature file and using TestNG but getting error: "cannot find class in classpath" and as a resolution of this I am geeting solution as add main class. Can anyone have another solution related to it.

error: org.testng.TestNGException: 
Cannot find class in classpath: crossfit.test.CroddfitRunner
    at org.testng.xml.XmlClass.loadClass(XmlClass.java:77)
    at org.testng.xml.XmlClass.init(XmlClass.java:69)
    at org.testng.xml.XmlClass.<init>(XmlClass.java:55)
    at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:575)
    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:38)
    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:152)
    at org.testng.xml.Parser.parse(Parser.java:233)
    at org.testng.TestNG.parseSuite(TestNG.java:295)
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:348)
    at org.testng.TestNG.initializeEverything(TestNG.java:995)
    at org.testng.remote.support.RemoteTestNG6_12.initialize(RemoteTestNG6_12.java:22)
    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)

2 Answers 2


You have to edit your testng.xml file. See this example:

<test name="Smoke Test"> 
 <class name="packagename.classname"> </class>

In , you must enter your tests package name before name of class that you want to run.


Please go through the below link and you can ask query here.


The above link didn't work it means you need a higher version of TestNG for the eclipse. Before that check TestNG is installed or not in order to know that press CTRL+N in the wizard you can see TestNG class file name.

If it is not displaying then try installing TestNG In Eclipse IDE Via Offline Jar Files:

1)Download the latest TestNG Jar files from the link TestNg Jars ("https://github.com/cbeust/testng-eclipse") 2)Download TestNG 6.11, Clicking on the link will download the “site_assembly.zip” file for the TestNG version 6.11. This file contains two folders named as “features” and “plugins“.Go to the eclipse installation directory and look for the “dropins” folder there. 3)Create a folder inside the dropins folder and name it as “testng-eclipse-6.11“ 4)Extract the “site_assembly.zip” file and copy its contents to the newly created “testng-eclipse-6.11” directory. 5)Restart Eclipse


Go click on Help> Install new Software> Under Available software> Work with textbox paste this "2019-06 - http://download.eclipse.org/releases/2019-06" and then click on ADD. You will now see the files like TestNG and a lot of many others. Select TestNG click on Next> Next> Accept the condtions> Finish. It will restart the eclipse. Inorder to know the installation is successful Press CTRL+N.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.