本文整理汇总了Java中org.testng.xml.XmlClass类的典型用法代码示例。如果您正苦于以下问题:Java XmlClass类的具体用法?Java XmlClass怎么用?Java XmlClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlClass类属于org.testng.xml包,在下文中一共展示了XmlClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.testng.xml.XmlClass; //导入依赖的package包/类
private void init(IClass cls,
ITestMethodFinder testMethodFinder,
IAnnotationFinder annotationFinder,
RunInfo runInfo,
XmlTest xmlTest,
XmlClass xmlClass)
{
log(3, "Creating TestClass for " + cls);
m_iClass = cls;
m_testClass = cls.getRealClass();
m_xmlTest = xmlTest;
m_xmlClass = xmlClass;
m_runInfo = runInfo;
m_testMethodFinder = testMethodFinder;
m_annotationFinder = annotationFinder;
initTestClassesAndInstances();
initMethods();
}
示例2: testOneTestMethod
import org.testng.xml.XmlClass; //导入依赖的package包/类
@Test
public void testOneTestMethod() throws Exception {
final XmlSuite suite = new XmlSuite();
final XmlTest test = new XmlTest();
final XmlClass xmlClass = new XmlClass("a.ATest", false);
xmlClass.getIncludedMethods().add(new XmlInclude("test1"));
test.getClasses().add(xmlClass);
suite.getTests().add(test);
doTest(suite,"##teamcity[enteredTheMatrix]\n" +
"\n" +
"##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://a.ATest']\n" +
"\n" +
"##teamcity[testStarted name='ATest.test1|[0|]' locationHint='java:test://a.ATest.test1|[0|]']\n" +
"\n" +
"##teamcity[testFinished name='ATest.test1|[0|]']\n");
}
示例3: testOneTestMethodWithMultipleInvocationCount
import org.testng.xml.XmlClass; //导入依赖的package包/类
@Test
public void testOneTestMethodWithMultipleInvocationCount() throws Exception {
final XmlSuite suite = new XmlSuite();
final XmlTest test = new XmlTest();
final XmlClass xmlClass = new XmlClass("a.ATest", false);
xmlClass.getIncludedMethods().add(new XmlInclude("test1", Arrays.asList(0, 1, 2), 0));
test.getClasses().add(xmlClass);
suite.getTests().add(test);
doTest(suite, "##teamcity[enteredTheMatrix]\n" +
"\n" +
"##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://a.ATest']\n" +
"\n" +
"##teamcity[testStarted name='ATest.test1|[0|]' locationHint='java:test://a.ATest.test1|[0|]']\n" +
"\n" +
"##teamcity[testFinished name='ATest.test1|[0|]']\n" +
"\n" +
"##teamcity[testStarted name='ATest.test1|[1|] (1)' locationHint='java:test://a.ATest.test1|[1|]']\n" +
"\n" +
"##teamcity[testFinished name='ATest.test1|[1|] (1)']\n" +
"\n" +
"##teamcity[testStarted name='ATest.test1|[2|] (2)' locationHint='java:test://a.ATest.test1|[2|]']\n" +
"\n" +
"##teamcity[testFinished name='ATest.test1|[2|] (2)']\n");
}
示例4: doTest
import org.testng.xml.XmlClass; //导入依赖的package包/类
private static void doTest(XmlSuite suite, String expected) {
final StringBuffer buf = new StringBuffer();
final IDEATestNGRemoteListener listener = createListener(buf);
for (XmlTest test : suite.getTests()) {
for (XmlClass aClass : test.getClasses()) {
final String classFQName = aClass.getName();
for (XmlInclude include : aClass.getIncludedMethods()) {
final String methodName = include.getName();
List<Integer> numbers = include.getInvocationNumbers();
if (numbers.isEmpty()) {
numbers = Collections.singletonList(0);
}
for (Integer integer : numbers) {
final MockTestNGResult result = new MockTestNGResult(classFQName, methodName, null, new Object[] {integer});
listener.onTestStart(result);
listener.onTestFinished(result);
}
}
}
}
Assert.assertEquals("output: " + buf, expected, StringUtil.convertLineSeparators(buf.toString()));
}
示例5: onStart
import org.testng.xml.XmlClass; //导入依赖的package包/类
@Override
public void onStart(ITestContext context) {
// This will only work if each test is run individually (test suite has only one running test)
// If there are multiple tests the the sandbox folder name is not provided and the GraphSandboxUtil provisions
// a unique name
List<XmlClass> testClassesToRun = context.getCurrentXmlTest().getClasses();
if (CollectionUtils.isNotEmpty(testClassesToRun) && 1 == testClassesToRun.size()) {
XmlClass currentTestClass = testClassesToRun.get(0);
if (null != currentTestClass && StringUtils.isNotEmpty(currentTestClass.getName())) {
GraphSandboxUtil.create(currentTestClass.getName());
} else {
GraphSandboxUtil.create();
}
} else {
GraphSandboxUtil.create();
}
}
示例6: getXmlSuite
import org.testng.xml.XmlClass; //导入依赖的package包/类
private XmlSuite getXmlSuite()
{
// we cannot use singletonLists here as testNG later
// modifies lists stored in XmlSuite ... zonk
XmlSuite testSuite = new XmlSuite();
testSuite.setName("tempto-tests");
testSuite.setFileName("tempto-tests");
XmlTest test = new XmlTest(testSuite);
test.setName("all");
XmlPackage testPackage = new XmlPackage(options.getTestsPackage());
List<XmlPackage> testPackages = newArrayList(testPackage);
test.setPackages(testPackages);
XmlClass conventionBasedTestsClass = new XmlClass("io.prestodb.tempto.internal.convention.ConventionBasedTestFactory");
List<XmlClass> classes = newArrayList(conventionBasedTestsClass);
test.setClasses(classes);
test.setParallel(XmlSuite.ParallelMode.METHODS);
return testSuite;
}
示例7: writeXmlClass
import org.testng.xml.XmlClass; //导入依赖的package包/类
public List<XmlClass> writeXmlClass(List<String> testcases, Map<String,
List<Method>> methods, List<XmlClass> xmlClasses) {
for (String className : methods.keySet()) {
if (className.contains("Test")) {
if (testcases.size() == 0) {
xmlClasses.add(createClass(className));
} else {
for (String s : testcases) {
for (int j = 0; j < items.size(); j++) {
String testName = items.get(j).concat("." + s).toString();
if (testName.equals(className)) {
xmlClasses.add(createClass(className));
}
}
}
}
}
}
return xmlClasses;
}
示例8: getClassBrowserConfiguration
import org.testng.xml.XmlClass; //导入依赖的package包/类
public static Optional<XmlConfig> getClassBrowserConfiguration(final XmlTest xmlTest, final String method) {
return StreamEx.of(xmlTest.getClasses())
.filter(xmlClass -> isMethodPresent(xmlClass, method))
.map(XmlClass::getAllParameters)
.map(parameters -> mapConfiguration(parameters, method))
.findFirst();
}
示例9: object
import org.testng.xml.XmlClass; //导入依赖的package包/类
@Override
public XmlTest object() throws TestException {
XmlTest xmlTest = new XmlTest();
xmlTest.setName(test.toString());
xmlTest.setXmlClasses(Collections.singletonList(new XmlClass(test.object(), false)));
return xmlTest;
}
示例10: runTests
import org.testng.xml.XmlClass; //导入依赖的package包/类
public void runTests(KWDTestCase kwdTestCase, String testSuiteName, String outputDirectory) {
this.kwdTestCase = kwdTestCase;
XmlSuite suite = new XmlSuite();
suite.setName(testSuiteName);
XmlTest xmlTest = new XmlTest(suite);
xmlTest.setName(kwdTestCase.getTestCaseName());
xmlTest.setVerbose(0);
System.out.println("Total number of Tests to be run: " + kwdTestCase.getTestMethods().size());
{
XmlClass xmlClass = new XmlClass("com.carteblanche.kwd.testng.TestNGDriver");
xmlTest.getClasses().add(xmlClass);
List<XmlInclude> xmlIncludeMethods = xmlClass.getIncludedMethods();
XmlInclude xmlInclude = new XmlInclude("runnableTest");
xmlIncludeMethods.add(xmlInclude);
xmlClass.setIncludedMethods(xmlIncludeMethods);
}
System.out.println("Running Tests using command ..");
testNG.setXmlSuites(Arrays.asList(suite));
testNG.setPreserveOrder(true);
testNG.setUseDefaultListeners(true);
testNG.setOutputDirectory(outputDirectory);
testNG.run();
}
示例11: TestClass
import org.testng.xml.XmlClass; //导入依赖的package包/类
protected TestClass(IClass cls,
ITestMethodFinder testMethodFinder,
IAnnotationFinder annotationFinder,
RunInfo runInfo,
XmlTest xmlTest,
XmlClass xmlClass) {
init(cls, testMethodFinder, annotationFinder, runInfo, xmlTest, xmlClass);
}
示例12: writeSuite
import org.testng.xml.XmlClass; //导入依赖的package包/类
public static File writeSuite(Map<String, Map<String, List<String>>> map,
Map<String, String> testParams,
String name,
String rootPath,
Logger logger) {
File xmlFile;
final XmlSuite xmlSuite = new XmlSuite();
xmlSuite.setParameters(testParams);
XmlTest xmlTest = new XmlTest(xmlSuite);
xmlTest.setName(name);
List<XmlClass> xmlClasses = new ArrayList<XmlClass>();
int idx = 0;
for (String className : map.keySet()) {
final XmlClass xmlClass = new XmlClass(className, idx++, false);
final Map<String, List<String>> collection = map.get(className);
if (collection != null) {
final ArrayList<XmlInclude> includedMethods = new ArrayList<XmlInclude>();
int mIdx = 0;
for (String methodName : collection.keySet()) {
final List<Integer> includes = new ArrayList<Integer>();
for (String include : collection.get(methodName)) {
try {
includes.add(Integer.parseInt(include));
}
catch (NumberFormatException e) {
logger.log(e);
}
}
includedMethods.add(new XmlInclude(methodName, includes, mIdx++));
}
xmlClass.setIncludedMethods(includedMethods);
}
xmlClasses.add(xmlClass);
}
xmlTest.setXmlClasses(xmlClasses);
xmlFile = new File(rootPath, "temp-testng-customsuite.xml");
final String toXml = xmlSuite.toXml();
writeToFile(logger, xmlFile, toXml);
return xmlFile;
}
示例13: createXmlTest
import org.testng.xml.XmlClass; //导入依赖的package包/类
protected XmlTest createXmlTest(XmlSuite suite, String name, String... classes) {
XmlTest result = new XmlTest(suite);
int index = 0;
result.setName(name);
for (String c : classes) {
XmlClass xc = new XmlClass(c, index++, true /* load classes */);
result.getXmlClasses().add(xc);
}
return result;
}
示例14: addMethods
import org.testng.xml.XmlClass; //导入依赖的package包/类
protected void addMethods(XmlClass cls, String... methods) {
int index = 0;
for (String m : methods) {
XmlInclude include = new XmlInclude(m, index++);
cls.getIncludedMethods().add(include);
}
}
示例15: getXmlClass
import org.testng.xml.XmlClass; //导入依赖的package包/类
/**
* @author Wasiq B
* @since 14-Dec-2014 8:48:22 pm
* @param loadClasses
* @return
*/
public XmlClass getXmlClass (final boolean loadClasses) {
final XmlClass cls = new XmlClass (this.className, loadClasses);
if (this.parameters != null) {
cls.setParameters (this.parameters);
}
cls.setName (this.className);
return cls;
}