java org.testng.TestNGException: 在尝试执行测试时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34433163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
org.testng.TestNGException: while trying to execute the tests
提问by Naman
I have been working on a project using Android Studio since long. Today refactored some code and it started to break,so reverted the changes. Even after reverting the changes whenever I try to debug the code, I am ending up with following an exception :
长期以来,我一直在使用 Android Studio 开发一个项目。今天重构了一些代码,它开始崩溃,所以恢复了更改。即使在我尝试调试代码时恢复更改后,我也会遇到以下异常:
org.testng.TestNGException: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 44; Attribute "parallel" with value "none" must have a value from the list "false methods tests classes instances ".
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:325)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:90)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:206)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:177)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:125)
Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 44; Attribute "parallel" with value "none" must have a value from the list "false methods tests classes instances ".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.validateDTDattribute(XMLDTDValidator.java:1392)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(XMLDTDValidator.java:1311)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1917)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:742)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:380)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:614)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3135)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:880)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
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:172)
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:305)
... 4 more
trying to open the project using intelliJ
I can get this gone. Any clues on this??
尝试使用intelliJ
我可以打开项目。这有什么线索吗??
采纳答案by Naman
Discussion and help from @juherr suggests that solution to this is :
@juherr 的讨论和帮助表明解决方案是:
Attribute "parallel" with value "none" must have a value from the list "false methods tests classes instances ".
TestNG 6.9.10 is now validating the xml file against the DTDThe problem is that the default testng.xml template from IntelliJ is setting "parallel" on suite to "none". Here is the link to the bugfor the same.
TestNG 6.9.10 现在正在根据DTD验证 xml 文件 问题是 IntelliJ 的默认 testng.xml 模板将套件上的“并行”设置为“无”。这是相同的错误的链接。
回答by Nabeel A.Rahman
update the testng.xml to
将 testng.xml 更新为
<suite name="Suite" parallel="false">
from
从
<suite name="Suite" parallel="none">
回答by Matthias M
If you have no editable testng.xml file, you can downgrade your testng dependency to 6.9.9.
如果您没有可编辑的 testng.xml 文件,则可以将 testng 依赖项降级到 6.9.9。
回答by Avinash Pande
If you are using/implementing any listener in your class/project then add the annotation @Listeners
on that class like below:
如果您在类/项目中使用/实现任何侦听器,则在该类上添加注释@Listeners
,如下所示:
@Listeners(value=SuiteListener.class)
e.g.
例如
@Listeners(value=ClassName who implemets listener.class)
e.g.
例如
@Listeners(value=SuiteListener.class)
public class SuiteListener implements ISuiteListener
{
lines of code / methods in class
}
Add below is a code snippet in testng.xml
下面添加的是testng.xml 中的代码片段
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<listeners>
<listener class-name="report.SuiteListener"></listener>
</listeners>
<test thread-count="5" name="Test">
<classes>
<class name="tests.Test1"/>
<class name="tests.Test2"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
回答by kartikeya mishra
Faced same problem and same exception. Worked for me by removing
面临同样的问题和同样的异常。通过删除对我来说有效
{parallel="none"}
or giving value
或给予价值
{parallel="false"}
in the testng.xml
file. Afterward runs fine.
在testng.xml
文件中。之后运行良好。