XmlTest中含有g(shù)roup, package, classes
創(chuàng)新互聯(lián)專注于三亞企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站開發(fā),商城系統(tǒng)網(wǎng)站開發(fā)。三亞網(wǎng)站建設(shè)公司,為三亞等地區(qū)提供建站服務(wù)。全流程按需網(wǎng)站策劃,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)初始化XmlClass,包含method,?include,?exclude
public class RunWithTestNgXml {
public static void main(String[] args) {
//Receive the arguments from command including groups, classes, package and so on
MapnodeValues = parseArgs(args);
ListxmlSuites = new ArrayList();
try {
//Could execute multiple suites
xmlSuites.add(getXmlSuite(nodeValues));
//Execute testng suites
TestNG testNG = new TestNG();
testNG.setXmlSuites(xmlSuites);
testNG.run();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
//Generate XmlSuite
private static XmlSuite getXmlSuite() throws ClassNotFoundException {
XmlSuite suite = new XmlSuite();
suite.setName("Suites");
suite.setConfigFailurePolicy(XmlSuite.FailurePolicy.CONTINUE);
//Set parallel as class
suite.setParallel(XmlSuite.ParallelMode.CLASSES);
//Set thread as 1
suite.setThreadCount(1);
//Set suite parameters
MapsuiteParams = generateSuiteMap();
suite.setParameters(suiteParams);
//Set test
ListxmlTests = getXmlTests(suite);
suite.setTests(xmlTests);
//if needed, also can write as testng.xml file
writeTestNgXml(suite);
return suite;
}
//Generate XmlTests
private static ListgetXmlTests(XmlSuite suite) {
ListxmlTestsList = new ArrayList();
XmlTest xmlTest = new XmlTest();
xmlTest.setName("Test");
xmlTest.setXmlSuite(xmlSuite);
//Set groups
Listgroups;
xmlTest.setIncludeGroups(groups);
//Set Packages
ListxmlPackages = new ArrayList();
xmlTest.setXmlPackages(xmlPackages);
//Set Classes
ListxmlClassList = new ArrayList();
xmlTest.setXmlClasses(xmlClassList);
xmlTestsList.add(xmlTest);
return xmlTestsList;
}
//Write testng.xml to disk
private static void writeTestNgXml(XmlSuite suite) {
String xmlStr = suite.toXml();
FileWriter writer = null;
try {
writer = new FileWriter( new File(C:/testng.xml"), false);
writer.write(xmlStr);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
writer.flush();
writer.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
四、執(zhí)行使用command?執(zhí)行main方法
cd {workspace}/build/libs/
java -cp {project}.jar com...RunWithTestNgXml groups=smoke,P0,test?classes=${CLASSES}?packages=${PACKAGES}?
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧