我是TestNG的新手。今天我尝试使用TestNG.xml运行四个测试用例。 我根据文档编写了代码并执行了它。一旦执行开始,我就得到了上述异常。我经历了之前提出的类似问题,并且知道我给出的包装名称是错误的。 任何人都可以告诉我我应该给出什么名称作为包名称我使用默认包。
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="MyFirstSuit">
<test name="MonsterOld" >
<classes>
<class name="default.MonsterUpdate" />
</classes>
</test>
<test name="MonsterNew">
<classes>
<class name="default.MonsterUpdateNewProfile"/>
</classes>
</test>
<test name="ShineOld">
<classes>
<class name="default.shineUpdate"/>
</classes>
</test>
<test name="ShineNew">
<classes>
<class name="default.shineUpdateNewProfile"/>
</classes>
</test>
Exception which i got for this xml file-
org.testng.TestNGException:
Cannot find class in classpath: default.MonsterUpdate
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:543)
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.XMLDocumentFragmentScannerImpl.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.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:17)
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:10)
at org.testng.xml.Parser.parse(Parser.java:168)
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)
答案 0 :(得分:1)
答案 1 :(得分:0)
获得异常的解决方案。 如果您使用默认包装,则不要在课程名称前写下任何包装名称。
新工作代码 -
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="MyFirstSuit">
<test name="MonsterOld" >
<classes>
<class name="MonsterUpdate" />
</classes>
</test>
<test name="MonsterNew">
<classes>
<class name="MonsterUpdateNewProfile"/>
</classes>
</test>
<test name="ShineOld">
<classes>
<class name="shineUpdate"/>
</classes>
</test>
<test name="ShineNew">
<classes>
<class name="shineUpdateNewProfile"/>
</classes>
</test>