@Override public int getInvocationCount() { return testNGMethod.getInvocationCount(); }
@Override public int getInvocationCount() { return testNGMethod.getInvocationCount(); }
@Override public void run() throws TestNGRuntimeException { // If there is an invocation time out, all the invocations need to be done within this // Runnable if (m_method.getInvocationTimeOut() > 0) { for (int i = 0; i < m_method.getInvocationCount(); i++) { runOne(); } } else { runOne(); } }
@Override public void run() throws TestNGRuntimeException { // If there is an invocation time out, all the invocations need to be done within this // Runnable if (m_method.getInvocationTimeOut() > 0) { for (int i = 0; i < m_method.getInvocationCount(); i++) { runOne(); } } else { runOne(); } }
if (tm.getInvocationCount() > 1) { sb.append(" ("); sb.append(tm.getCurrentInvocationCount()); sb.append(" of "); sb.append(tm.getInvocationCount()); sb.append(")"); if (!isConfMethod && tm.getInvocationCount() > 1) { sb.append(" success: "); sb.append(tm.getSuccessPercentage());
if (tm.getInvocationCount() > 1) { sb.append(" ("); sb.append(tm.getCurrentInvocationCount()); sb.append(" of "); sb.append(tm.getInvocationCount()); sb.append(")"); if (!isConfMethod && tm.getInvocationCount() > 1) { sb.append(" success: "); sb.append(tm.getSuccessPercentage());
/** * An exception was thrown by the test, determine if this method * should be marked as a failure or as failure_but_within_successPercentage */ private void handleException(Throwable throwable, ITestNGMethod testMethod, ITestResult testResult, int failureCount) { if (throwable != null && testResult.getThrowable() == null) { testResult.setThrowable(throwable); } int successPercentage= testMethod.getSuccessPercentage(); int invocationCount= testMethod.getInvocationCount(); float numberOfTestsThatCanFail= ((100 - successPercentage) * invocationCount) / 100f; if(failureCount < numberOfTestsThatCanFail) { testResult.setStatus(ITestResult.SUCCESS_PERCENTAGE_FAILURE); } else { testResult.setStatus(ITestResult.FAILURE); } }
/** * An exception was thrown by the test, determine if this method should be marked as a failure or * as failure_but_within_successPercentage */ protected void handleException( Throwable throwable, ITestNGMethod testMethod, ITestResult testResult, int failureCount) { if (throwable != null && testResult.getThrowable() == null) { testResult.setThrowable(throwable); } int successPercentage = testMethod.getSuccessPercentage(); int invocationCount = testMethod.getInvocationCount(); float numberOfTestsThatCanFail = ((100 - successPercentage) * invocationCount) / 100f; if (failureCount < numberOfTestsThatCanFail) { testResult.setStatus(ITestResult.SUCCESS_PERCENTAGE_FAILURE); } else { testResult.setStatus(ITestResult.FAILURE); } }
/** * Invokes a method that has a specified threadPoolSize. */ private List<ITestResult> invokePooledTestMethods(ITestNGMethod testMethod, XmlSuite suite, Map<String, String> parameters, ConfigurationGroupMethods groupMethods, ITestContext testContext) { // // Create the workers // List<IWorker<ITestNGMethod>> workers = Lists.newArrayList(); // Create one worker per invocationCount for (int i = 0; i < testMethod.getInvocationCount(); i++) { // we use clones for reporting purposes ITestNGMethod clonedMethod= testMethod.clone(); clonedMethod.setInvocationCount(1); clonedMethod.setThreadPoolSize(1); MethodInstance mi = new MethodInstance(clonedMethod); workers.add(new SingleTestMethodWorker(this, mi, suite, parameters, testContext, m_classListeners)); } return runWorkers(testMethod, workers, testMethod.getThreadPoolSize(), groupMethods, suite, parameters); }
/** Invokes a method that has a specified threadPoolSize. */ private List<ITestResult> invokePooledTestMethods( ITestNGMethod testMethod, XmlSuite suite, Map<String, String> parameters, ConfigurationGroupMethods groupMethods, ITestContext testContext) { // // Create the workers // List<IWorker<ITestNGMethod>> workers = Lists.newArrayList(); // Create one worker per invocationCount for (int i = 0; i < testMethod.getInvocationCount(); i++) { // we use clones for reporting purposes ITestNGMethod clonedMethod = testMethod.clone(); clonedMethod.setInvocationCount(1); clonedMethod.setThreadPoolSize(1); MethodInstance mi = new MethodInstance(clonedMethod); workers.add(new SingleTestMethodWorker(this, invoker, mi, parameters, testContext, m_classListeners)); } return runWorkers( testMethod, workers, testMethod.getThreadPoolSize(), groupMethods, suite, parameters); }
if (testMethod.getInvocationCount() > 1 && testMethod.getThreadPoolSize() > 1) { return invokePooledTestMethods(testMethod, suite, parameters, groupMethods, testContext); timeOutInvocationCount > 0; int invocationCount = onlyOne ? 1 : testMethod.getInvocationCount();
if (testMethod.getInvocationCount() > 1 && testMethod.getThreadPoolSize() > 1) { return invokePooledTestMethods(testMethod, suite, parameters, groupMethods, context); ITestNGMethod[] afterMethods = TestNgMethodUtils.filterAfterTestMethods(testClass, CAN_RUN_FROM_CLASS); int invocationCount = onlyOne ? 1 : testMethod.getInvocationCount();
@Override public int getInvocationCount() { return delegate.getInvocationCount(); }
@Override public int getInvocationCount() { return delegate.getInvocationCount(); }
@Override public int getInvocationCount() { return method.getInvocationCount(); }
public static String appendTestMethodName(String testName, ITestNGMethod m) { int invocationID = -1; if (m.getInvocationCount() > 1) { invocationID = m.getCurrentInvocationCount() + 1; } if (invocationID != -1) { // TODO: analyze if "InvCount=nnnn" is already present in name and don't append it one more time testName = testName + " - " + adjustTestName(m) + String.format(SpecialKeywords.INVOCATION_COUNTER, String.format("%04d", invocationID)); } else { testName = testName + " - " + adjustTestName(m); } return StringEscapeUtils.escapeHtml4(testName); }
public static String appendTestMethodName(String testName, ITestNGMethod m) { int invocationID = -1; if (m.getInvocationCount() > 1) { invocationID = m.getCurrentInvocationCount() + 1; } if (invocationID != -1) { // TODO: analyze if "InvCount=nnnn" is already present in name and don't append it one more time testName = testName + " - " + adjustTestName(m) + String.format(SpecialKeywords.INVOCATION_COUNTER, String.format("%04d", invocationID)); } else { testName = testName + " - " + adjustTestName(m); } return StringEscapeUtils.escapeHtml4(testName); }
private String getMethodInvocationsAndSuccessPercentage(ITestResult iTestResult) { int percentage = iTestResult.getMethod().getSuccessPercentage(); int curCount = iTestResult.getMethod().getCurrentInvocationCount() + 1; int iCount = iTestResult.getMethod().getInvocationCount(); String invoc = ""; if (iCount > 1) { invoc = ":" + curCount + "/" + iCount; if (percentage > 0) { invoc = invoc + " " + percentage + "%"; } } return invoc; }
@Override public String getName(ITestResult result) { // Start milliseconds of test long millis = result.getStartMillis(); // Hash code to distinguish several test instances of the same // class. Collisions can be ignored for small amount of test objects int hash = result.getInstance().hashCode(); // Test instance class name String clazz = result.getTestClass().getRealClass().getSimpleName(); // Test name (usually test method name) String test = result.getName(); // Test method current invocation. If method has only one invocation, // the prefix is omitted String invocation = ""; // FIXME getCurrentInvocationCount fails in parallel mode ITestNGMethod testNGMethod = result.getMethod(); if (testNGMethod.getInvocationCount() > 1) { invocation = "." + testNGMethod.getCurrentInvocationCount(); } String name = millis + "." + hash + invocation + "-" + clazz + "." + test; return name; }
/** * Counts a number of the methods and printed it to the output stream with the test suite name. * * @param suite test suite */ public void onSuiteStart(ISuite suite) { if (suite != null) { try { List<ITestNGMethod> allMethods = suite.getAllMethods(); if (allMethods != null) { int count = 0; for (ITestNGMethod method : allMethods) { if (method.isTest()) { count += method.getInvocationCount(); } } methodCount(out, count); } } catch (NoSuchMethodError ignore) { } rootPresentation(out, suite.getName(), suite.getXmlSuite().getFileName()); } }