TestNG Exception on Mac: Cannot find class in classpath ...!

When I try to run the test suite, I get this exception on the Mac, we use maven projects here, today the morning eclipse was paused, and I did a forced shutdown and then restarted the same, and later could not run the tests. I did an update, cleanup, reinstall testNG, reconfigured eclipse with a new eclipse instance, and imported maven projects, but then also get the same exception. The same maven projects will work on another Mac, Pls offers any methods that are not here.

also referred to solutions presented in the following links: SO link 1 SO link 2

Error Console:

org.testng.TestNGException: Cannot find class in classpath: com.adobe.store.polarBear.polarBearSuite.tests.ReaderAIHTest at org.testng.xml.XmlClass.loadClass(XmlClass.java:81) at org.testng.xml.XmlClass.init(XmlClass.java:73) at org.testng.xml.XmlClass.<init>(XmlClass.java:59) at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:539) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501) at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:788) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) at javax.xml.parsers.SAXParser.parse(SAXParser.java:395) at javax.xml.parsers.SAXParser.parse(SAXParser.java:198) at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:17) at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:1) at org.testng.xml.Parser.parse(Parser.java:172) at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:311) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) 
+4
source share
5 answers

Go to Project -> Clean

It works for me

+6
source

A few suggestions: 1. Go to your target folder and check if .class is available for ReaderAIHTest? 2. Go to Run As -> Maven Build -> Enter the target as a clean test compilation (I assume your case is in src / test / java.)

+2
source

Do you use the Run Configuration feature in eclipse? If so, make sure you use the correct testng.xml for the test you are trying to run. Sometimes you use the wrong one or the one that was automatically created in the "Run Configuration" menu in eclipse.

0
source

if your package name is TEST_Package and the class name is DEMO_TEST , then the code in xml should be

 classes class name="TEST_Package.DEMO_TEST" classes 

you try it ...... it will work

0
source

I ran into the same problem. After synchronizing the code with the repo, when I updated my project in eclipse. The package name begins with src.test.java.com ......

so the whole problem is the .classpath file in your modules directory Do 'mvn eclipse: eclipse' it will regenerate your .classpath file. And then upgrade your project in an eclipse.

0
source

All Articles