@Override public Class<?> getRealClass() { return xmlClass.getSupportClass(); }
private static List<String> createQualifiedMethodNames(XmlClass xmlClass, List<String> methods) { List<String> vResult = Lists.newArrayList(); Class<?> cls = xmlClass.getSupportClass(); while (cls != null) { for (String im : methods) { Pattern pattern = Pattern.compile(methodName(im)); Method[] allMethods = ReflectionHelper.getLocalMethods(cls); for (Method m : allMethods) { if (pattern.matcher(m.getName()).matches()) { vResult.add(makeMethodName(m.getDeclaringClass().getName(), m.getName())); } } } cls = cls.getSuperclass(); } return vResult; }
private static List<String> createQualifiedMethodNames(XmlClass xmlClass, List<String> methods) { List<String> vResult = Lists.newArrayList(); Class<?> cls = xmlClass.getSupportClass(); while (cls != null) { for (String im : methods) { Pattern pattern = Pattern.compile(methodName(im)); Method[] allMethods = ReflectionHelper.getLocalMethods(cls); for (Method m : allMethods) { if (pattern.matcher(m.getName()).matches()) { vResult.add(makeMethodName(m.getDeclaringClass().getName(), m.getName())); } } } cls = cls.getSuperclass(); } return vResult; }
public ClassInfoMap(List<XmlClass> classes, boolean includeNested) { includeNestedClasses = includeNested; for (XmlClass xmlClass : classes) { try { Class<?> c = xmlClass.getSupportClass(); registerClass(c, xmlClass); } catch (NoClassDefFoundError e) { Utils.log("[ClassInfoMap]", 1, "Unable to open class " + xmlClass.getName() + " - unable to resolve class reference " + e.getMessage()); if (xmlClass.loadClasses()) { throw e; } } } }
/** * 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(); }
public ClassInfoMap(List<XmlClass> classes, boolean includeNested) { includeNestedClasses = includeNested; for (XmlClass xmlClass : classes) { try { Class<?> c = xmlClass.getSupportClass(); registerClass(c, xmlClass); } catch (NoClassDefFoundError e) { Utils.log( "[ClassInfoMap]", 1, "Unable to open class " + xmlClass.getName() + " - unable to resolve class reference " + e.getMessage()); if (xmlClass.loadClasses()) { throw e; } } } }
/** * 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(); } }
public void setXmlClasses(List<XmlClass> classes) { m_classes = classes; for (XmlClass c : classes) { for (XmlInclude m : c.getIncludedMethods()) { checkMethod(c.getSupportClass(), m.getName()); String methodName = makeMethodName(c.getName(), m.getName()); m_includedMethods.put(methodName, m); } } }
Class<?> cls = xmlClass.getSupportClass(); if (!assignable(methodClass, cls)) { continue;
public void setXmlClasses(List<XmlClass> classes) { m_classes = classes; for (XmlClass c : classes) { for (XmlInclude m : c.getIncludedMethods()) { checkMethod(c.getSupportClass(), m.getName()); String methodName = makeMethodName(c.getName(), m.getName()); m_includedMethods.put(methodName, m); } } }
Class<?> cls = xmlClass.getSupportClass(); if (!assignable(methodClass, cls)) { continue;
XmlClass[] classes = ClassHelper.findClassesInSameTest(tm.getRealClass(), suite); for(XmlClass xmlClass : classes) { setClassInvocationFailure(xmlClass.getSupportClass(), instance);
XmlClass[] classes = ClassHelper.findClassesInSameTest(tm.getRealClass(), suite); for (XmlClass xmlClass : classes) { setClassInvocationFailure(xmlClass.getSupportClass(), instance);
private void checkClassAnnotations(List<String> errors, Set<Class> processedClasses, ITestNGMethod m) { // Class of the test instance Class<?> testClass = m.getTestClass().getRealClass(); // Check that the test instance's class matches the XmlTest's support class // They can be different if a test inherits a @Factory method and doesn't override it // Ignore multiple classes in the same XmlTest, which can happen when running from the IDE // or when the testName is incorrect (handled below) if (m.getXmlTest().getXmlClasses().size() == 1) { Class xmlClass = m.getXmlTest().getXmlClasses().get(0).getSupportClass(); if (xmlClass != testClass && processedClasses.add(xmlClass)) { errors.add("Class " + xmlClass.getName() + " must override the @Factory method from base class " + testClass.getName()); return; } } if (!processedClasses.add(testClass)) return; // Check that the testName in the @Test annotation is set and matches the test class // All tests with the same testName or without a testName run in the same XmlTest // which means they also run in the same thread, not in parallel Test annotation = testClass.getAnnotation(Test.class); if (annotation == null || annotation.testName().isEmpty()) { errors.add("Class " + testClass.getName() + " does not have a testName"); return; } if (!annotation.testName().contains(testClass.getSimpleName())) { errors.add("Class " + testClass.getName() + " has an invalid testName: " + annotation.testName()); } }
protected void resetSingleXmlSuite(XmlSuite suite) { for (XmlTest xmlTest : suite.getTests()) { for (XmlClass xmlClass : xmlTest.getClasses()) { Class testClass = xmlClass.getSupportClass(); if (testClass.getAnnotation(TestNGOnArk.class) != null) { if (!DelegateArkContainer.isStarted()) { DelegateArkContainer.launch(testClass); ClassLoaderUtils.pushContextClassLoader(ClassLoader.getSystemClassLoader()); } try { xmlClass.setClass(DelegateArkContainer.getTestClassLoader().loadClass( testClass.getCanonicalName())); } catch (ClassNotFoundException ex) { throw new ArkRuntimeException(String.format( "Load testNG test class %s failed.", testClass.getCanonicalName()), ex); } } } } }
@Override public void onFinish(ITestContext context) { Class testClass = context.getCurrentXmlTest().getXmlClasses().get(0).getSupportClass(); TestResourceTracker.testFinished(testClass.getName()); } }
@Override public void onStart(ITestContext context) { Class testClass = context.getCurrentXmlTest().getXmlClasses().get(0).getSupportClass(); TestResourceTracker.testStarted(testClass.getName()); }
Set<String> clsSet = clses.stream() .map(x -> { String sptCls = x.getSupportClass().toString(); sptCls = sptCls.replace("class ", ""); return sptCls;