/** 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()); } }
/** * 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 || method == null) { return -1; } 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; }
/** {@inheritDoc} */ @Override public void setTestClass(ITestClass tc) { if (tc == null) { throw new IllegalArgumentException("test class cannot be null"); } boolean assignable = m_method.getDeclaringClass().isAssignableFrom(tc.getRealClass()); if (!assignable) { throw new IllegalArgumentException( "mismatch in classes between " + tc.getName() + " and " + m_method.getDeclaringClass().getName()); } m_testClass = tc; }
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>"); } }
m_methodIndex += 1; ITestClass testClass = method.getTestClass(); String className = testClass.getName(); if (mq == 0) { String id = (m_testIndex == null ? null : "t" + Integer.toString(m_testIndex));
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); m_out.println("<p class=\"totop\"><a href=\"#summary\">back to summary</a></p>"); } }
@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; }
.append("')\n") .append("data.setCell(").append(index).append(", 2, '") .append(m.getTestClass().getName()).append("')\n") .append("data.setCell(").append(index) .append(", 3, ").append(time).append(");\n");
+ "1, '" + m.getMethodName() + "')\n") .append("data.setCell(" + index + ", " + "2, '" + m.getTestClass().getName() + "')\n") .append("data.setCell(" + index + ", " + "3, " + time + ");\n");
m_methodIndex += 1; ITestClass testClass = method.getTestClass(); String className = testClass.getName(); if (mq == 0) { String id = (m_testIndex == null ? null : "t" + Integer.toString(m_testIndex));
@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; }
private void init(ITestNGMethod method, ITestContext ctx, Throwable t, long start, long end) { m_throwable = t; m_instanceName = method.getTestClass().getName(); if (null == m_throwable) { m_status = ITestResult.SUCCESS;
/** Returns the name of the executed test. */ private static String getTestName(IInvokedMethod method) { return StringUtils.substringAfterLast(method.getTestMethod().getTestClass().getName(), ".") + "#" + method.getTestMethod().getConstructorOrMethod().getName(); }
protected static void logMessage() { ITestResult iTestResult = Reporter.getCurrentTestResult(); String method = iTestResult.getMethod().getMethodName(); String clazz = iTestResult.getMethod().getTestClass().getName(); messages.add(clazz + "." + method); } }