2016-12-23 77 views
-2

我對TestNG框架相當新穎。我沒有從鏈接http://beust.com/eclipse下載TestNG。發佈後,我創建了一個名爲MyProject的新Java項目和一個新的TestNG類文件「NewTest」。我用@Test註釋編寫了一小段代碼來啓動Firefox瀏覽器並導航到Google。我試圖在網絡上搜索可能的解決方案來解決這個問題,但我無法找到關於如何糾正的低級步驟。請幫忙。TestNG設置問題 - 在類路徑中找不到類

輸出

org.testng.TestNGException: Cannot find class in classpath: NewTest 
    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:582) 
    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:170) 
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:305) 
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:109) 
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)  
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81) 

enter image description here

回答

0

移動Package1內部src目錄,並運行該代碼。

注: Eclipse中運行從src目錄.java文件,並在bin目錄中創建.class文件。

0

看來我沒有更新我的Eclipse幾個月。我沒有導航到Eclipse->幫助 - >檢查更新 - >完成安裝所有更新。發佈這個測試確實運行良好。

相關問題