本文整理匯總了Java中org.testng.xml.XmlSuite.setListeners方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlSuite.setListeners方法的具體用法?Java XmlSuite.setListeners怎麽用?Java XmlSuite.setListeners使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.testng.xml.XmlSuite
的用法示例。
在下文中一共展示了XmlSuite.setListeners方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepareMock
import org.testng.xml.XmlSuite; //導入方法依賴的package包/類
protected ITestResult prepareMock(Class<?> tClass, Method method) {
ITestResult result = mock(ITestResult.class);
IClass clazz = mock(IClass.class);
ITestNGMethod testNGMethod = mock(ITestNGMethod.class);
ConstructorOrMethod cm = mock(ConstructorOrMethod.class);
String methodName = method.getName();
when(result.getTestClass()).thenReturn(clazz);
when(result.getTestClass().getRealClass()).thenReturn(tClass);
when(clazz.getName()).thenReturn(this.getClass().getName());
when(result.getMethod()).thenReturn(testNGMethod);
when(cm.getMethod()).thenReturn(method);
when(result.getMethod().getConstructorOrMethod()).thenReturn(cm);
when(testNGMethod.getMethodName()).thenReturn(methodName);
ITestContext context = mock(ITestContext.class);
when(result.getTestContext()).thenReturn(context);
XmlTest xmlTest = new XmlTest();
XmlSuite suite = new XmlSuite();
xmlTest.setXmlSuite(suite);
suite.setListeners(Arrays.asList(VideoListener.class.getName()));
when(context.getCurrentXmlTest()).thenReturn(xmlTest);
return result;
}
示例2: constructXmlSuiteForParallel
import org.testng.xml.XmlSuite; //導入方法依賴的package包/類
public XmlSuite constructXmlSuiteForParallel(String pack, List<String> testcases,
Map<String, List<Method>> methods,
int deviceCount, ArrayList<String> deviceSerail) {
ArrayList<String> listeners = new ArrayList<>();
listeners.add("com.appium.manager.AppiumParallelTestListener");
listeners.add("com.appium.utils.RetryListener");
include(listeners, "LISTENERS");
include(groupsInclude, "INCLUDE_GROUPS");
include(groupsExclude, "EXCLUDE_GROUPS");
XmlSuite suite = new XmlSuite();
suite.setName("TestNG Forum");
suite.setThreadCount(deviceCount);
suite.setDataProviderThreadCount(deviceCount);
suite.setParallel(ParallelMode.TESTS);
suite.setVerbose(2);
suite.setListeners(listeners);
for (int i = 0; i < deviceCount; i++) {
XmlTest test = new XmlTest(suite);
test.setName("TestNG Test" + i);
test.setPreserveOrder("false");
test.addParameter("device", deviceSerail.get(i));
test.setIncludedGroups(groupsInclude);
test.setExcludedGroups(groupsExclude);
List<XmlClass> xmlClasses = new ArrayList<>();
writeXmlClass(testcases, methods, xmlClasses);
test.setXmlClasses(xmlClasses);
}
System.out.println(suite.toXml());
writeTestNGFile(suite);
return suite;
}
示例3: constructXmlSuiteForDistribution
import org.testng.xml.XmlSuite; //導入方法依賴的package包/類
public XmlSuite constructXmlSuiteForDistribution(String pack, List<String> tests,
Map<String, List<Method>> methods,
int deviceCount) {
include(listeners, "LISTENERS");
include(groupsInclude, "INCLUDE_GROUPS");
XmlSuite suite = new XmlSuite();
suite.setName("TestNG Forum");
suite.setThreadCount(deviceCount);
suite.setParallel(ParallelMode.CLASSES);
suite.setVerbose(2);
listeners.add("com.appium.manager.AppiumParallelMethodTestListener");
listeners.add("com.appium.utils.RetryListener");
suite.setListeners(listeners);
if (prop.getProperty("LISTENERS") != null) {
suite.setListeners(listeners);
}
XmlTest test = new XmlTest(suite);
test.setName("TestNG Test");
test.addParameter("device", "");
include(groupsExclude, "EXCLUDE_GROUPS");
test.setIncludedGroups(groupsInclude);
test.setExcludedGroups(groupsExclude);
List<XmlClass> xmlClasses = new ArrayList<>();
writeXmlClass(tests, methods, xmlClasses);
test.setXmlClasses(xmlClasses);
System.out.println(suite.toXml());
writeTestNGFile(suite);
return suite;
}
示例4: constructXmlSuiteForDistributionMethods
import org.testng.xml.XmlSuite; //導入方法依賴的package包/類
public XmlSuite constructXmlSuiteForDistributionMethods(String pack, List<String> tests,
Map<String, List<Method>> methods,
int deviceCount) {
include(listeners, "LISTENERS");
include(groupsInclude, "INCLUDE_GROUPS");
XmlSuite suite = new XmlSuite();
suite.setName("TestNG Forum");
suite.setThreadCount(deviceCount);
suite.setDataProviderThreadCount(deviceCount);
suite.setVerbose(2);
suite.setParallel(ParallelMode.METHODS);
listeners.add("com.appium.manager.AppiumParallelMethodTestListener");
listeners.add("com.appium.utils.RetryListener");
suite.setListeners(listeners);
if (prop.getProperty("LISTENERS") != null) {
suite.setListeners(listeners);
}
List<XmlClass> xmlClasses = new ArrayList<>();
xmlClasses = writeXmlClass(tests, methods, xmlClasses);
XmlTest test = new XmlTest(suite);
test.setName("TestNG Test");
test.addParameter("device", "");
include(groupsExclude, "EXCLUDE_GROUPS");
test.setIncludedGroups(groupsInclude);
test.setExcludedGroups(groupsExclude);
List<XmlClass> writeXml = new ArrayList<>();
for (int i = 0; i < xmlClasses.size(); i++) {
writeXml.add(new XmlClass(xmlClasses.get(i).getName()));
test.setClasses(writeXml);
}
System.out.println(suite.toXml());
writeTestNGFile(suite);
return suite;
}