@Override public ITestClass getTestClass() { return testNGMethod.getTestClass(); }
@Override public ITestClass getTestClass() { return m_method.getTestClass(); }
@Override public int compare(ITestNGMethod o1, ITestNGMethod o2) { String c1 = o1.getTestClass().getName(); String c2 = o2.getTestClass().getName(); return c1.compareTo(c2); } };
private static String constructMethodNameUsingTestClass(String currentMethodName, ITestNGMethod m) { int lastIndex = currentMethodName.lastIndexOf('.'); if (lastIndex != -1) { return m.getTestClass().getRealClass().getName() + currentMethodName.substring(lastIndex); } return currentMethodName; }
/** * Remove the method from this map and returns true if it is the last * of its class. */ public boolean removeAndCheckIfLast(ITestNGMethod m, Object instance) { Collection<ITestNGMethod> l = classMap.get(instance); if (l == null) { throw new AssertionError("l should not be null"); } l.remove(m); // It's the last method of this class if all the methods remaining in the list belong to a // different class for (ITestNGMethod tm : l) { if (tm.getEnabled() && tm.getTestClass().equals(m.getTestClass())) { return false; } } return true; }
private static String constructMethodNameUsingTestClass( String currentMethodName, ITestNGMethod m) { int lastIndex = currentMethodName.lastIndexOf('.'); if (lastIndex != -1) { return m.getTestClass().getRealClass().getName() + currentMethodName.substring(lastIndex); } return currentMethodName; } }
/** Finds topmost position of the test method in the stack, or top of stack if <code>method</code> is not in it. */ public static int getTestRoot(StackTraceElement[] stack,ITestNGMethod method) { if(stack!=null) { String cname = method.getTestClass().getName(); for(int x=stack.length-1; x>=0; x--) { if(cname.equals(stack[x].getClassName()) && method.getMethodName().equals(stack[x].getMethodName())) { return x; } } return stack.length-1; } else { return -1; } }
@Override public boolean isTrue(ITestNGMethod m, IClass c) { return c == null || m.getTestClass().getName().equals(c.getName()); } }
public TestResult(IClass testClass, Object instance, ITestNGMethod method, Throwable throwable, long start, long end, ITestContext context) { init(testClass, instance, method, throwable, start, end, context); }
private void addResults(Set<ITestResult> allResults, Map<Class<?>, Set<ITestResult>> out) { for (ITestResult tr : allResults) { Class<?> cls = tr.getMethod().getTestClass().getRealClass(); Set<ITestResult> l = out.get(cls); if (l == null) { l = Sets.newHashSet(); out.put(cls, l); } l.add(tr); } }
private static List<IMethodInstance> findClasses(List<IMethodInstance> methodInstances, Class<?> c) { List<IMethodInstance> result = Lists.newArrayList(); for (IMethodInstance mi : methodInstances) { if (mi.getMethod().getTestClass().getRealClass() == c) { result.add(mi); } } return result; }
private void addResults(Set<ITestResult> allResults, Map<Class<?>, Set<ITestResult>> out) { for (ITestResult tr : allResults) { Class<?> cls = tr.getMethod().getTestClass().getRealClass(); Set<ITestResult> l = out.computeIfAbsent(cls, k -> Sets.newHashSet()); l.add(tr); } }
private void resultDetail(IResultMap tests) { for (ITestResult result : tests.getAllResults()) { ITestNGMethod method = result.getMethod(); m_methodIndex++; String cname = method.getTestClass().getName(); m_out.println("<h2 id=\"m" + m_methodIndex + "\">" + cname + ":" + method.getMethodName() + "</h2>"); generateForResult(result, method); m_out.println("<p class=\"totop\"><a href=\"#summary\">back to summary</a></p>"); } }
private void p(List<IMethodInstance> methods, String s) { System.out.println("[PreserveOrderMethodInterceptor] " + s); for (IMethodInstance mi : methods) { System.out.println(" " + mi.getMethod().getMethodName() + " index:" + mi.getMethod().getTestClass().getXmlClass().getIndex()); } }
private ITestResult registerSkippedTestResult(ITestNGMethod testMethod, Object instance, long start, Throwable throwable) { ITestResult result = new TestResult(testMethod.getTestClass(), instance, testMethod, throwable, start, System.currentTimeMillis(), m_testContext); result.setStatus(TestResult.SKIP); Reporter.setCurrentTestResult(result); runTestListeners(result); return result; }
/** * @return the test results that apply to one of the instances of the testMethod. */ private Set<ITestResult> keepSameInstances(ITestNGMethod method, Set<ITestResult> results) { Set<ITestResult> result = Sets.newHashSet(); for (ITestResult r : results) { Object o = method.getInstance(); // Keep this instance if 1) It's on a different class or 2) It's on the same class // and on the same instance Object instance = r.getInstance() != null ? r.getInstance() : r.getMethod().getInstance(); if (r.getTestClass() != method.getTestClass() || instance == o) result.add(r); } return result; }
/** * Run all the ITestNGMethods passed in through the constructor. * * @see java.lang.Runnable#run() */ @Override public void run() { for (IMethodInstance testMthdInst : m_methodInstances) { ITestNGMethod testMethod = testMthdInst.getMethod(); ITestClass testClass = testMethod.getTestClass(); invokeBeforeClassMethods(testClass, testMthdInst); // Invoke test method try { invokeTestMethods(testMethod, testMthdInst.getInstance(), m_testContext); } finally { invokeAfterClassMethods(testClass, testMthdInst); } } }
/** * Store the result of parameterTypes and optionalValues after filter out injected types */ final static class FilterOutInJectedTypesResult { private Class<?>[] parameterTypes; private String[] optionalValues; private FilterOutInJectedTypesResult(Class<?>[] parameterTypes, String[] optionalValues) { this.parameterTypes = parameterTypes; this.optionalValues = optionalValues; } Class<?>[] getParameterTypes() { return parameterTypes; } String[] getOptionalValues() { return optionalValues; } }
/** Returns the name of the executed test. */ private static String getTestName(IInvokedMethod method) { return StringUtils.substringAfterLast(method.getTestMethod().getTestClass().getName(), ".") + "#" + method.getTestMethod().getConstructorOrMethod().getName(); }
@Override public String getContent(ISuite suite, XMLStringBuffer main) { XMLStringBuffer xsb = new XMLStringBuffer(main.getCurrentIndent()); SetMultiMap<Class<?>, ITestNGMethod> map = Maps.newSetMultiMap(); for (ITestNGMethod method : suite.getExcludedMethods()) { map.put(method.getTestClass().getRealClass(), method); } for (Class<?> c : map.keySet()) { xsb.push(D, C, "ignored-class-div"); xsb.addRequired(S, c.getName(), C, "ignored-class-name"); xsb.push(D, C, "ignored-methods-div"); for (ITestNGMethod m : map.get(c)) { xsb.addRequired(S, m.getMethodName(), C, "ignored-method-name"); xsb.addEmptyElement("br"); } xsb.pop(D); xsb.pop(D); } return xsb.toXML(); }