org.testng.TestNGException:尝试执行测试时

时间:2015-12-23 10:08:04

标签: java android-studio testng intellij-15

我一直在使用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

尝试使用intelliJ打开项目我可以解决这个问题。关于这个的任何线索??

5 个答案:

答案 0 :(得分:3)

来自@juherr的讨论和帮助表明解决方案是:

Attribute "parallel" with value "none" must have a value from the list "false methods tests classes instances ".

TestNG 6.9.10现在正在针对DTD验证xml文件 问题是IntelliJ的默认testng.xml模板将套件上的“parallel”设置为“none”。 以下是指向bug的链接。

答案 1 :(得分:2)

将testng.xml更新为

showRightFab(viewPager.getCurrentItem());

<suite name="Suite" parallel="false">

答案 2 :(得分:0)

如果您没有可编辑的testng.xml文件,则可以将testng依赖项降级为6.9.9。

答案 3 :(得分:0)

如果您要在类/项目中使用/实现任何侦听器,请在该类上添加注释@Listeners,如下所示-
@Listeners(value = SuiteListener.class)
例如
@Listeners(值=实现listener.class的ClassName)
例如
@Listeners(value = SuiteListener.class)
公共类SuiteListener实现ISuiteListener
{
    类中的代码行/方法
}

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 -->

答案 4 :(得分:-1)

面临同样的问题和同样的异常。通过删除

为我工作
{parallel="none"}

或给予价值

{parallel="false"}
<{1>}文件中的

。之后运行良好。