Skip to main content
3 of 3
typos fixed
pavelsaman
  • 4.5k
  • 1
  • 14
  • 37

TestNG with Eclipse: How to add main class?

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)