@Override @SuppressWarnings("rawtypes") public void transform(final ITestAnnotation test, final Class testClass, final Constructor testConstructor, final Method testMethod) { //Set DataProvider for the test if (testMethod != null){ if(dataType(testMethod)!=null) { if(dataType(testMethod).equals(Data.PROPERTIES)) { test.setDataProviderClass(DataSources.class); test.setDataProvider(dataPropertiesSource); } else if(dataType(testMethod).equals(Data.EXCEL)){ test.setDataProviderClass(DataSources.class); test.setDataProvider(dataExcelSource); } } } //Set retry analyzer class for all @Test methods IRetryAnalyzer retry = test.getRetryAnalyzer(); if (retry==null){ test.setRetryAnalyzer(RetryAnalyzer.class); } }
@Override public void onTestFailure(ITestResult result) { int count = RetryCounter.getRunCount(); int maxCount = RetryAnalyzer.getMaxRetryCountForTest(); LOGGER.debug("count: " + count + "; maxCount:" + maxCount); IRetryAnalyzer retry = result.getMethod().getRetryAnalyzer(); if (count < maxCount && retry == null) { LOGGER.error("retry_count will be ignored as RetryAnalyzer is not declared for " + result.getMethod().getMethodName()); } if (count < maxCount && retry != null && !Jira.isRetryDisabled(result)) { failRetryItem(result, Messager.RETRY_RETRY_FAILED, count, maxCount); } else { failItem(result, Messager.TEST_FAILED); afterTest(result); } super.onTestFailure(result); }
@SuppressWarnings("rawtypes") @Override public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) { IRetryAnalyzer retry = annotation.getRetryAnalyzer(); if (retry == null) { annotation.setRetryAnalyzer(TestngRetry.class); } // 设置 默认循环次数 ConfigUtil property = ConfigUtil.getInstance(); int count = Integer.valueOf(property.getProperty("loopCount")); LogUtil.info("默认每个方法循环" + count + "次"); annotation.setInvocationCount(count); // 设置 需要特殊处理方法的循环次数 String excepLoopCount = property.getProperty("excepLoopCount"); String[] excepCount = excepLoopCount.split(";"); for (int i = 0; i < excepCount.length; i++) { String[] temp = excepCount[i].split(","); if (testMethod.getName().equals(temp[0])) { LogUtil.info("该方法循环" + temp[1] + "次"); annotation.setInvocationCount(Integer.valueOf(temp[1])); } } }
@SuppressWarnings("rawtypes") public void transform(final ITestAnnotation annotation, final Class testClass, final Constructor testConstructor, final Method testMethod) { final IRetryAnalyzer retry = annotation.getRetryAnalyzer(); if (retry == null) { annotation.setRetryAnalyzer(Retry.class); } }
@Override public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) { IRetryAnalyzer retry = annotation.getRetryAnalyzer(); if (retry == null) { annotation.setRetryAnalyzer(TestngRetry.class); } }
public void transform(final ITestAnnotation annotation, final Class testClass, final Constructor testConstructor, final Method testMethod) { IRetryAnalyzer retryAnalyzer = annotation.getRetryAnalyzer(); if (retryAnalyzer == null) { annotation.setRetryAnalyzer(TestRetryAnalyzer.class); } }
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) { IRetryAnalyzer analyzer = annotation.getRetryAnalyzer(); if (analyzer == null) { annotation.setRetryAnalyzer(FailedTestsRetryListner.class); } }
/** * * @param result */ @Override public void onTestStart(ITestResult result) { RetryTestContext context = getRetryContext(result); if (context != null) { if (result.getMethod().getRetryAnalyzer() == null) { IRetryAnalyzer retryAnalyzer = new RetryTestAnalyzer(context); result.getMethod().setRetryAnalyzer(retryAnalyzer); } } }
/** * * @param result */ @Override public void onTestFailure(ITestResult result) { IRetryAnalyzer retryAnalyzer = result.getMethod().getRetryAnalyzer(); if(retryAnalyzer instanceof RetryTestAnalyzer){ RetryTestAnalyzer retryTestAnalyzer = (RetryTestAnalyzer) retryAnalyzer; if (retryTestAnalyzer.willRetry()) { result.setStatus(TestResult.SKIP); } } // RetryTestContext context = getRetryContext(result); // if (context != null) { // // IRetryAnalyzer retryAnalyzer = result.getMethod().getRetryAnalyzer(); // Assert.assertTrue(retryAnalyzer instanceof RetryTestAnalyzer, "RetryAnalyzer wasn't initialized first."); // RetryTestAnalyzer analyzer = (RetryTestAnalyzer) retryAnalyzer; // // // It's too late to change the TestResult Status in the Retry Analyzer so it // // must be set here. Feel free to set it to PASS if desired. // if (analyzer.willRetry()) { // result.setStatus(TestResult.SKIP); // } // } }
@Override public void onTestSkipped(ITestResult result) { ExtentTestManager.extent.removeTest(ExtentTestManager.getTest()); IRetryAnalyzer retryAnalyzer = result.getMethod().getRetryAnalyzer(); if (((Retry) retryAnalyzer).retryCountForTest == ((Retry) retryAnalyzer).maxRetryCount) { (reportManager.parentTest.get()).getModel().setStatus(Status.SKIP); (reportManager.childTest.get()).getModel().setStatus(Status.SKIP); ExtentManager.getExtent().flush(); } }
@Override public void transform(ITestAnnotation iTestAnnotation, Class aClass, Constructor constructor, Method method) { IRetryAnalyzer retry = iTestAnnotation.getRetryAnalyzer(); if (retry == null) { iTestAnnotation.setRetryAnalyzer(Retry.class); } }
public static BaseTestRetryAnalyzer getIRA(ITestResult result) { IRetryAnalyzer ira = result.getMethod().getRetryAnalyzer(); if (ira instanceof BaseTestRetryAnalyzer) { ira = (BaseTestRetryAnalyzer)ira; } else { ira = new BaseTestRetryAnalyzer(); } return (BaseTestRetryAnalyzer) ira; }
@Override public void transform(ITestAnnotation annotation, Class testClass, Constructor constructor, Method method) { IRetryAnalyzer retry = annotation.getRetryAnalyzer(); if(retry == null) { annotation.setRetryAnalyzer(RetryFailed.class); } }
@SuppressWarnings("rawtypes") @Override public void transform(ITestAnnotation testAnnotation, Class clazz, Constructor test, Method method) { IRetryAnalyzer retry = testAnnotation.getRetryAnalyzer(); if (retry == null) { testAnnotation.setRetryAnalyzer(RetryAnalyzer.class); } LOGGER.debug("retry analyzer: " + method.getName() + testAnnotation.getRetryAnalyzer()); }
@Override public IRetryAnalyzer getRetryAnalyzer() { return delegate.getRetryAnalyzer(); }
@Override public void setRetryAnalyzer(IRetryAnalyzer retryAnalyzer) { delegate.setRetryAnalyzer(retryAnalyzer); }