@Override public int getCurrentInvocationCount() { return testNGMethod.getCurrentInvocationCount(); }
@Override public int getCurrentInvocationCount() { return testNGMethod.getCurrentInvocationCount(); }
static Object getMethodInvocationToken(ITestNGMethod method, Object instance) { return String.format("%s+%d+%d", instance.toString(), method.getCurrentInvocationCount(), method.getParameterInvocationCount()); }
static Object getMethodInvocationToken(ITestNGMethod method, Object instance) { return String.format( "%s+%d+%d", instance.toString(), method.getCurrentInvocationCount(), method.getParameterInvocationCount()); }
private static boolean isConfigMethodRunningFirstTime(ConfigurationMethod cm, ITestNGMethod tm) { return !cm.isFirstTimeOnly() || (cm.isFirstTimeOnly() && tm.getCurrentInvocationCount() == 0); }
private static boolean doesSetupMethodPassFirstTimeFilter( ConfigurationMethod cm, ITestNGMethod tm) { return !cm.isFirstTimeOnly() || (cm.isFirstTimeOnly() && tm.getCurrentInvocationCount() == 0); }
sb.append(tm.getCurrentInvocationCount()); sb.append(" of "); sb.append(tm.getInvocationCount());
sb.append(tm.getCurrentInvocationCount()); sb.append(" of "); sb.append(tm.getInvocationCount());
@Override public int getCurrentInvocationCount() { return delegate.getCurrentInvocationCount(); }
@Override public int getCurrentInvocationCount() { return delegate.getCurrentInvocationCount(); }
private String getCompletedTestLabel(ITestNGMethod test) { String invocationLabel = ""; if (test.getCurrentInvocationCount() > 1) { invocationLabel = format(" (run %d)", test.getCurrentInvocationCount()); } return getTestLabel(test, invocationLabel); }
private String getStartingTestLabel(ITestNGMethod test) { String invocationLabel = ""; if (test.getCurrentInvocationCount() > 0) { invocationLabel = format(" (run %d)", test.getCurrentInvocationCount() + 1); } return getTestLabel(test, invocationLabel); }
@Override public int getCurrentInvocationCount() { return method.getCurrentInvocationCount(); }
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); }
@Override protected void executeTest() { ITestNGMethod testNGMethod = Reporter.getCurrentTestResult().getMethod(); run(Reporter.getCurrentTestResult(), ReflectionUtils.findMethod(this.getClass(), "configure"), createTestLoader(this.getClass().getSimpleName(), this.getClass().getPackage().getName()), testNGMethod.getCurrentInvocationCount()); }
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 void checkDuplicatesAndAdd(ITestResult tr) { // Need fully qualified name to guarantee uniqueness in the results map String instanceName = tr.getInstanceName(); String key = instanceName + "." + testName(tr); if (m_allTests.containsKey(key)) { if (tr.getMethod().getCurrentInvocationCount() == 1) { System.err.println("[" + this.getClass().getSimpleName() + "] Test case '" + key + "' already exists in the results"); tr.setStatus(ITestResult.FAILURE); tr.setThrowable(new IllegalStateException("Duplicate test: " + key)); } List<ITestResult> itrList = m_allTests.get(key); itrList.add(tr); m_allTests.put(key, itrList); } else { ArrayList<ITestResult> itrList = new ArrayList<>(); itrList.add(tr); m_allTests.put(key, itrList); } } }
/** * Executes the test case. * @deprecated in favor of using {@link com.consol.citrus.annotations.CitrusXmlTest} or {@link com.consol.citrus.annotations.CitrusTest} annotations on test methods. */ @Deprecated protected void executeTest() { if (citrus == null) { citrus = Citrus.newInstance(applicationContext); } ITestResult result = Reporter.getCurrentTestResult(); ITestNGMethod testNGMethod = result.getMethod(); TestContext context = prepareTestContext(citrus.createTestContext()); TestLoader testLoader = createTestLoader(this.getClass().getSimpleName(), this.getClass().getPackage().getName()); TestCase testCase = testLoader.load(); testCase.setGroups(testNGMethod.getGroups()); resolveParameter(result, testNGMethod.getConstructorOrMethod().getMethod(), testCase, context, testNGMethod.getCurrentInvocationCount()); citrus.run(testCase, context); }
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; }