2012年3月15日

解決 org.testng.TestNGException: Cannot find class in classpath


 
今天在使用 TestNG 時出現了下面的訊息,
org.testng.TestNGException: Cannot find class in classpath。
解決方法很簡單,在 Eclipse 上方的選單中,
選擇 Project -> Clean,接著等他重新 build 完就可以了。

圖片來源:http://www.pushtotest.com/pushtotest-for-developers.html

附上錯誤訊息:
org.testng.TestNGException:
Cannot find class in classpath: werdna1222coldcodes.blogspot.com.demo.xxx
 at org.testng.xml.XmlClass.loadClass(XmlClass.java:76)
 at org.testng.xml.XmlClass.init(XmlClass.java:68)
 at org.testng.xml.XmlClass.(XmlClass.java:54)
 at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:500)
 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:2755)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
 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:10)
 at org.testng.xml.Parser.parse(Parser.java:170)
 at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:276)
 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)

關鍵字:TestNG, TestNGException, Cannot find class in classpath
參考資料:


更多精選推薦文章