从eclipse复制的依赖注解,一运行测试脚本发现报错如下:
"F:Program FilesJavajdk1.7.0_17injava" -ea -Didea.launcher.port=7533 "-Didea.launcher.bin.path=F:Program Files (x86)JetBrainsIntelliJ IDEA 14.1in" -Dfile.encoding=UTF-8 -classpath "F:Program Files (x86)JetBrainsIntelliJ IDEA 14.1plugins estnglib estng-plugin.jar;F:Program FilesJavajdk1.7.0_17jrelibcharsets.jar;F:Program FilesJavajdk1.7.0_17jrelibdeploy.jar;F:Program FilesJavajdk1.7.0_17jrelibjavaws.jar;F:Program FilesJavajdk1.7.0_17jrelibjce.jar;F:Program FilesJavajdk1.7.0_17jrelibjfr.jar;F:Program FilesJavajdk1.7.0_17jrelibjfxrt.jar;F:Program FilesJavajdk1.7.0_17jrelibjsse.jar;F:Program FilesJavajdk1.7.0_17jrelibmanagement-agent.jar;F:Program FilesJavajdk1.7.0_17jrelibplugin.jar;F:Program FilesJavajdk1.7.0_17jrelib
esources.jar;F:Program FilesJavajdk1.7.0_17jrelib
t.jar;F:Program FilesJavajdk1.7.0_17jrelibextaccess-bridge-64.jar;F:Program FilesJavajdk1.7.0_17jrelibextdnsns.jar;F:Program FilesJavajdk1.7.0_17jrelibextjaccess.jar;F:Program FilesJavajdk1.7.0_17jrelibextlocaledata.jar;F:Program FilesJavajdk1.7.0_17jrelibextsunec.jar;F:Program FilesJavajdk1.7.0_17jrelibextsunjce_provider.jar;F:Program FilesJavajdk1.7.0_17jrelibextsunmscapi.jar;F:Program FilesJavajdk1.7.0_17jrelibextzipfs.jar;E:workespacedemotest argetclasses;E:
epositoryorg estng estng6.9.10 estng-6.9.10.jar;E:
epositorycomeustjcommander1.48jcommander-1.48.jar;E:
epositoryorgeanshellsh2.0b4sh-2.0b4.jar;E:
epositoryselenium-server-standaloneselenium-server-standalone2.53selenium-server-standalone-2.53.jar;F:Program Files (x86)JetBrainsIntelliJ IDEA 14.1plugins estnglib estng.jar;F:Program Files (x86)JetBrainsIntelliJ IDEA 14.1libidea_rt.jar" com.intellij.rt.execution.application.AppMain org.testng.RemoteTestNGStarter -port 65416 -usedefaultlisteners false -socket65417 -temp F: empidea_testng4.tmp
org.testng.TestNGException: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 44; 值为 "none" 的属性 "parallel" 必须具有列表 "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)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 44; 值为 "none" 的属性 "parallel" 必须具有列表 "false methods tests classes instances " 中的值。
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
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:437)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
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:376)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3065)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:881)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
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)
... 9 more
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Process finished with exit code 0
解决方案:
原因为6.9.10版本的testng,开始验证xml中的元素;而idea默认的testng.xml模板中parallel设置为none,因此报错。
所以解决方法:
1. testng 使用6.9.9
或者
2. testng使用6.9.10, 在testng.xml中parallel设置为false
效果如下: