XmlInclude xi = new XmlInclude(methodName);
private String findDescription(ITestAnnotation testAnnotation, XmlTest xmlTest) { String result = testAnnotation.getDescription(); if (result == null) { List<XmlClass> classes = xmlTest.getXmlClasses(); for (XmlClass c : classes) { if (c.getName().equals(m_method.getMethod().getDeclaringClass().getName())) { for (XmlInclude include : c.getIncludedMethods()) { if (include.getName().equals(m_method.getName())) { result = include.getDescription(); if (result != null) { break; } } } } } } return result; }
private static void toYaml(StringBuilder result, String sp, XmlInclude xi) { result.append(sp).append("- name: ").append(xi.getName()).append("\n"); String sp2 = sp + " "; toYaml(result, sp2, xi.getLocalParameters()); }
XmlInclude include; if (!Utils.isStringEmpty(in)) { include = new XmlInclude(name, stringToList(in), m_currentIncludeIndex++); } else { include = new XmlInclude(name, m_currentIncludeIndex++); include.addParameter(entry.getKey(), entry.getValue()); include.setDescription(m_currentInclude.description); m_currentIncludedMethods.add(include);
int ind = 0; for(ITestNGMethod m: methodList) { XmlInclude methodName = new XmlInclude(m.getConstructorOrMethod().getName(), m.getFailedInvocationNumbers(), ind++); methodName.setParameters(findMethodLocalParameters(srcXmlTest, m)); methodNames.add(methodName);
protected static XmlInclude createXmlInclude(XmlClass clazz, String method) { XmlInclude include = new XmlInclude(method); include.setXmlClass(clazz); clazz.getIncludedMethods().add(include); return include; }
protected static XmlInclude createXmlInclude(XmlClass clazz, String method, Map<String, String> params) { XmlInclude include = createXmlInclude(clazz, method); include.setParameters(params); return include; }
@Test public void testDescriptionInclusion() throws Exception { final String xml = getPathToResource("xml/simple-suite-with-method-desc.xml"); SuiteXmlParser parser = new SuiteXmlParser(); TestNGContentHandler handler = new TestNGContentHandler(xml, false); parser.parse(new FileInputStream(xml), handler); List<XmlInclude> includes = handler.getSuite().getTests().get(0).getXmlClasses().get(0).getIncludedMethods(); String desc = includes.get(0).getDescription(); Assert.assertEquals("simple-description", desc); }
break; case PASS_INCLUDE: includeF.getLocalParameters().put("a", "Correct"); break;
/** * @deprecated Use {@code getLocalParameters()} or {@code getAllParameters()} */ @Deprecated public Map<String, String> getParameters() { return getAllParameters(); }
XmlInclude include; if (!Utils.isStringEmpty(in)) { include = new XmlInclude(name, stringToList(in), m_currentIncludeIndex++); } else { include = new XmlInclude(name, m_currentIncludeIndex++); include.addParameter(entry.getKey(), entry.getValue()); include.setDescription(m_currentInclude.description); m_currentIncludedMethods.add(include); } else if (null != m_currentDefines) {
for (ITestNGMethod m : methodList) { XmlInclude methodName = new XmlInclude( m.getConstructorOrMethod().getName(), m.getFailedInvocationNumbers(), ind++); methodName.setParameters(findMethodLocalParameters(srcXmlTest, m)); methodNames.add(methodName);
protected static XmlInclude createXmlInclude(XmlClass clazz, String method, int index, Integer... list) { XmlInclude include = new XmlInclude(method, Arrays.asList(list), index); include.setXmlClass(clazz); clazz.getIncludedMethods().add(include); return include; }
/** @deprecated Use {@code getLocalParameters()} or {@code getAllParameters()} */ @Deprecated public Map<String, String> getParameters() { return getAllParameters(); }
protected static void addMethods(XmlClass cls, String... methods) { int index = 0; for (String method : methods) { XmlInclude include = new XmlInclude(method, index++); cls.getIncludedMethods().add(include); } }
/** * Get local parameters of one include method from origin test xml. * @param srcXmlTest The {@link XmlTest} object that represents the source. * @param method the method we want to find its parameters * @return local parameters belong to one test method. */ private static Map<String, String> findMethodLocalParameters(XmlTest srcXmlTest, ITestNGMethod method) { Class clazz = method.getRealClass(); for (XmlClass c : srcXmlTest.getClasses()) { if (clazz == c.getSupportClass()) { for (XmlInclude xmlInclude : c.getIncludedMethods()) { if (xmlInclude.getName().equals(method.getMethodName())) { return xmlInclude.getLocalParameters(); } } } } return Collections.emptyMap(); }
private String findDescription(ITestAnnotation testAnnotation, XmlTest xmlTest) { String result = testAnnotation.getDescription(); if (result == null) { List<XmlClass> classes = xmlTest.getXmlClasses(); for (XmlClass c : classes) { if (c.getName().equals(m_method.getMethod().getDeclaringClass().getName())) { for (XmlInclude include : c.getIncludedMethods()) { if (include.getName().equals(m_method.getName())) { result = include.getDescription(); if (result != null) { break; } } } } } } return result; }
XmlInclude xi = new XmlInclude(methodName);
@Override public Map<String, String> findMethodParameters(XmlTest test) { // Get the test+suite parameters Map<String, String> result = test.getAllParameters(); for (XmlClass xmlClass: test.getXmlClasses()) { if (xmlClass.getName().equals(getTestClass().getName())) { result.putAll(xmlClass.getLocalParameters()); for (XmlInclude include : xmlClass.getIncludedMethods()) { if (include.getName().equals(getMethodName())) { result.putAll(include.getLocalParameters()); break; } } } } return result; }
String className = split[0]; if (xc.getName().equals(className)) { XmlInclude includedMethod = new XmlInclude(split[1]); xc.getIncludedMethods().add(includedMethod);