/** * Constructs a <code>BaseTestMethod</code> TODO cquezel JavaDoc. * * @param method * @param annotationFinder * @param instance */ public BaseTestMethod(String methodName, Method method, IAnnotationFinder annotationFinder, Object instance) { this(methodName, new ConstructorOrMethod(method), annotationFinder, instance); }
private static ConstructorOrMethod getMethod(Test t) { String name = null; try { Method nameMethod = t.getClass().getMethod("getName"); name = (String) nameMethod.invoke(t); return new ConstructorOrMethod(t.getClass().getMethod(name)); } catch (Throwable th) { Utils.log("JUnit3TestMethod", 2, "Method '" + name + "' not found in class '" + t + "': " + th.getMessage()); return null; } } }
public static IConfigurationAnnotation findConfiguration(IAnnotationFinder finder, Constructor ctor) { return findConfiguration(finder, new ConstructorOrMethod(ctor)); }
public static IConfigurationAnnotation findConfiguration(IAnnotationFinder finder, Method m) { return findConfiguration(finder, new ConstructorOrMethod(m)); }
ITestNGMethod confMethod = new ConfigurationMethod(new ConstructorOrMethod(method), annotationFinder, isBeforeSuite,
public static IConfigurationAnnotation findConfiguration(IAnnotationFinder finder, Method m) { return findConfiguration(finder, new ConstructorOrMethod(m)); }
private static ConstructorOrMethod getMethod(Test t) { String name = null; try { Method nameMethod = t.getClass().getMethod("getName"); name = (String) nameMethod.invoke(t); return new ConstructorOrMethod(t.getClass().getMethod(name)); } catch (Throwable th) { Utils.log( "JUnit3TestMethod", 2, "Method '" + name + "' not found in class '" + t + "': " + th.getMessage()); return null; } } }
ITestNGMethod confMethod = new ConfigurationMethod( new ConstructorOrMethod(method), annotationFinder, isBeforeSuite,
private TestNGMethod( Method method, IAnnotationFinder finder, boolean initialize, XmlTest xmlTest, Object instance) { super(method.getName(), new ConstructorOrMethod(method), finder, instance); setXmlTest(xmlTest); if (initialize) { init(xmlTest); } }
private static ConstructorOrMethod getMethod(Description desc) { Class<?> c = desc.getTestClass(); String method = desc.getMethodName(); if (JUnit4SpockMethod.isSpockClass(c)) { return new JUnit4SpockMethod(desc); } if (method == null) { return new JUnit4ConfigurationMethod(c); } // remove [index] from method name in case of parameterized test int idx = method.indexOf('['); if (idx != -1) { method = method.substring(0, idx); } try { return new ConstructorOrMethod(c.getMethod(method)); } catch (Throwable t) { Utils.log("JUnit4TestMethod", 2, "Method '" + method + "' not found in class '" + c.getName() + "': " + t.getMessage()); return null; } }
/** * For the given class, returns the method annotated with @Factory or null * if none is found. This method does not search up the superclass hierarchy. * If more than one method is @Factory annotated, a TestNGException is thrown. * @param cls The class to search for the @Factory annotation. * @param finder The finder (JDK 1.4 or JDK 5.0+) use to search for the annotation. * * @return the @Factory <CODE>methods</CODE> */ public static List<ConstructorOrMethod> findDeclaredFactoryMethods(Class<?> cls, IAnnotationFinder finder) { List<ConstructorOrMethod> result = new ArrayList<>(); for (Method method : getAvailableMethods(cls)) { IFactoryAnnotation f = finder.findAnnotation(method, IFactoryAnnotation.class); if (f != null) { ConstructorOrMethod factory = new ConstructorOrMethod(method); factory.setEnabled(f.getEnabled()); result.add(factory); } } for (Constructor constructor : cls.getDeclaredConstructors()) { IFactoryAnnotation f = finder.findAnnotation(constructor, IFactoryAnnotation.class); if (f != null) { ConstructorOrMethod factory = new ConstructorOrMethod(constructor); factory.setEnabled(f.getEnabled()); result.add(factory); } } return result; }
private static ConstructorOrMethod getMethod(Class<?> c, Description desc) { String method = desc.getMethodName(); if (JUnit4SpockMethod.isSpockClass(c)) { return new JUnit4SpockMethod(desc); } if (method == null) { return new JUnit4ConfigurationMethod(c); } // remove [index] from method name in case of parameterized test int idx = method.indexOf('['); if (idx != -1) { method = method.substring(0, idx); } try { return new ConstructorOrMethod(c.getMethod(method)); } catch (Throwable t) { Utils.log( "JUnit4TestMethod", 2, "Method '" + method + "' not found in class '" + c.getName() + "': " + t.getMessage()); return null; } }
public FakeTestNGMethod(Class<?> clazz, String methodName, XmlTest xmlTest) { ConstructorOrMethod temp = null; Method[] methods = ReflectionHelper.getLocalMethods(clazz); for (Method method : methods) { if (method.getName().equalsIgnoreCase(methodName)) { temp = new ConstructorOrMethod(method); break; } } this.xmlTest = xmlTest; this.clazz = clazz; this.consMethod = temp; }
BiConsumer<IFactoryAnnotation, Executable> consumer = (f, executable) -> { if (f != null) { ConstructorOrMethod factory = new ConstructorOrMethod(executable); factory.setEnabled(f.getEnabled()); result.add(factory);
new ConstructorOrMethod(m), new MethodParameters( params, methodParams, parameterValues, currentTestMeth, ctx, testResult),
Object instance) this(new ConstructorOrMethod(method), annotationFinder, isBeforeSuite, isAfterSuite, isBeforeTest, isAfterTest, isBeforeClass, isAfterClass, isBeforeMethod, isAfterMethod, beforeGroups, afterGroups, instance);
@Override public ConstructorOrMethod getConstructorOrMethod() { return new ConstructorOrMethod(getMethod()); }