是否可以通过TestNG SuiteRunner类运行多个以运行多个TestNG xmls。 我创建了Runner Class:
package com.util;
import java.util.ArrayList;
import java.util.List;
import org.testng.TestNG;
public class Runner {
public static void main(String[] args) {
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<String>();
suitefiles.add("<path of Xml 1>");
suitefiles.add("<path of Xml 2>");
runner.setDefaultSuiteName("test");
runner.setTestSuites(suitefiles);
runner.run();
}
}
执行上述类文件时发生以下错误:
Exception in thread "main" org.testng.TestNGException: java.lang.NullPointerException
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:320)
at org.testng.TestNG.run(TestNG.java:1021)
at com.util.Runner.main(Runner.java:19)
Caused by: java.lang.NullPointerException
at org.testng.xml.TestNGContentHandler.endElement(TestNGContentHandler.java:712)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.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:38)
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:300)
... 2 more
谢谢和问候