@Override public Class<?> getRealClass() { return testNGMethod.getRealClass(); }
private static boolean equalsEffectiveClass(ITestNGMethod m1, ITestNGMethod m2) { try { Class c1 = m1.getRealClass(); Class c2 = m2.getRealClass(); return c1 == null ? c2 == null : c1.equals(c2); } catch(Exception ex) { return false; } }
private static boolean belongToDifferentClassHierarchy(ITestNGMethod baseClassMethod, ITestNGMethod derivedClassMethod) { return ! baseClassMethod.getRealClass().isAssignableFrom(derivedClassMethod.getRealClass()); }
@Override public Class<?> getRealClass() { return testNGMethod.getRealClass(); }
private static boolean equalsEffectiveClass(ITestNGMethod m1, ITestNGMethod m2) { try { Class c1 = m1.getRealClass(); Class c2 = m2.getRealClass(); return c1 == null ? c2 == null : c1.equals(c2); } catch (Exception ex) { return false; } }
@Override public int compare(ITestNGMethod o1, ITestNGMethod o2) { int result = -2; Class<?> thisClass = o1.getRealClass(); Class<?> otherClass = o2.getRealClass(); if (thisClass.isAssignableFrom(otherClass)) { result = -1; } else if (otherClass.isAssignableFrom(thisClass)) { result = 1; } else if (o1.equals(o2)) { result = 0; } return result; } };
private static boolean belongToDifferentClassHierarchy( ITestNGMethod baseClassMethod, ITestNGMethod derivedClassMethod) { return !baseClassMethod.getRealClass().isAssignableFrom(derivedClassMethod.getRealClass()); }
/** * Generate a HTML color based on the class of the method */ private String createColor(ITestNGMethod tm) { // real class can be null if this client is remote (not serializable) long color = tm.getRealClass() != null ? tm.getRealClass().hashCode() & 0xffffff: 0xffffff; long[] rgb = { ((color & 0xff0000) >> 16) & 0xff, ((color & 0x00ff00) >> 8) & 0xff, color & 0xff }; // Not too dark for (int i = 0; i < rgb.length; i++) { if (rgb[i] < 0x60) { rgb[i] += 0x60; } } long adjustedColor = (rgb[0] << 16) | (rgb[1] << 8) | rgb[2]; return Long.toHexString(adjustedColor); }
private Properties getPropertiesFor(ITestNGMethod method, long elapsedTimeMillis) { Properties attrs= new Properties(); String name= Utils.detailedMethodName(method, false); attrs.setProperty(XMLConstants.ATTR_NAME, name); attrs.setProperty(XMLConstants.ATTR_CLASSNAME, method.getRealClass().getName()); attrs.setProperty(XMLConstants.ATTR_TIME, Double.toString(((double) elapsedTimeMillis) / 1000)); return attrs; }
private TestTag createIgnoredTestTagFor(ITestNGMethod method) { TestTag testTag = new TestTag(); Properties p2 = new Properties(); p2.setProperty(XMLConstants.ATTR_CLASSNAME, method.getRealClass().getName()); p2.setProperty(XMLConstants.ATTR_NAME, method.getMethodName()); testTag.childTag = XMLConstants.SKIPPED; testTag.properties = p2; return testTag; }
private Properties getPropertiesFor(ITestNGMethod method, long elapsedTimeMillis) { Properties attrs = new Properties(); String name = Utils.detailedMethodName(method, false); attrs.setProperty(XMLConstants.ATTR_NAME, name); attrs.setProperty(XMLConstants.ATTR_CLASSNAME, method.getRealClass().getName()); attrs.setProperty(XMLConstants.ATTR_TIME, Double.toString(((double) elapsedTimeMillis) / 1000)); return attrs; }
private void addMapping(SetMultiMap<Class<?>, ITestNGMethod> mapping, Collection<ITestNGMethod> methods) { for (ITestNGMethod method : methods) { if (! method.getEnabled()) { mapping.put(method.getRealClass(), method); } } } }
private TestTag createIgnoredTestTagFor(ITestNGMethod method) { TestTag testTag = new TestTag(); Properties p2 = new Properties(); p2.setProperty(XMLConstants.ATTR_CLASSNAME, method.getRealClass().getName()); p2.setProperty(XMLConstants.ATTR_NAME, method.getMethodName()); testTag.childTag = XMLConstants.SKIPPED; testTag.properties = p2; return testTag; }
private void addMapping( SetMultiMap<Class<?>, ITestNGMethod> mapping, Collection<ITestNGMethod> methods) { for (ITestNGMethod method : methods) { if (!method.getEnabled()) { mapping.put(method.getRealClass(), method); } } } }
private void writeSuiteGroups(XMLStringBuffer xmlBuffer, ISuite suite) { xmlBuffer.push(XMLReporterConfig.TAG_GROUPS); Map<String, Collection<ITestNGMethod>> methodsByGroups = suite.getMethodsByGroups(); for (Map.Entry<String, Collection<ITestNGMethod>> entry : methodsByGroups.entrySet()) { Properties groupAttrs = new Properties(); groupAttrs.setProperty(XMLReporterConfig.ATTR_NAME, entry.getKey()); xmlBuffer.push(XMLReporterConfig.TAG_GROUP, groupAttrs); Set<ITestNGMethod> groupMethods = getUniqueMethodSet(entry.getValue()); for (ITestNGMethod groupMethod : groupMethods) { Properties methodAttrs = new Properties(); methodAttrs.setProperty(XMLReporterConfig.ATTR_NAME, groupMethod.getMethodName()); methodAttrs.setProperty(XMLReporterConfig.ATTR_METHOD_SIG, groupMethod.toString()); methodAttrs.setProperty(XMLReporterConfig.ATTR_CLASS, groupMethod.getRealClass().getName()); xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_METHOD, methodAttrs); } xmlBuffer.pop(); } xmlBuffer.pop(); }
/** * 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(); }
@DataProvider(name = "dp1") public Object[][] createData(ITestNGMethod m) { Assert.assertEquals(m.getMethodName(), "test1"); Assert.assertEquals(m.getConstructorOrMethod().getMethod().getName(), "test1"); Assert.assertEquals(m.getRealClass(), ITestNGMethodSample.class); return new Object[][] {{"Cedric"}, {"Alois"}}; }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { String clazz = method.getTestMethod().getRealClass().getSimpleName() + "."; ordered.add(clazz + method.getTestMethod().getMethodName()); } }
private ParameterHandler.ParameterBag invokeParameterCreation(ITestNGMethod method) { ITestContext context = new FakeTestContext(method.getRealClass()); Map<String, String> map = Maps.newHashMap(); return handler.createParameters(method, map, map, context); } }
private TestNgRunStateTracker.EventLogBuilder buildEventLog(ITestResult result, TestNgRunEvent event) { return(buildEventLog(result.getTestContext(), event)) .addData(METHOD_NAME, result.getMethod().getMethodName()) .addData(CLASS_NAME, result.getMethod().getRealClass().getCanonicalName()) .addData(CLASS_INSTANCE, result.getMethod().getInstance()) .addData(GROUPS_DEPENDED_ON, result.getMethod().getGroupsDependedUpon()) .addData(METHODS_DEPENDED_ON, result.getMethod().getMethodsDependedUpon()) .addData(GROUPS_BELONGING_TO, result.getMethod().getGroups()); }