org.testng.IRetryAnalyzer Java Examples

The following examples show how to use org.testng.IRetryAnalyzer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RetryListener.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void transform(ITestAnnotation testannotation, Class testClass,
    Constructor testConstructor, Method testMethod) {
  IRetryAnalyzer retry = testannotation.getRetryAnalyzer();

  if (retry == null) {
    testannotation.setRetryAnalyzer(Retry.class);
  }
}
 
Example #2
Source File: RetryListener.java    From WebAndAppUITesting with GNU General Public License v3.0 5 votes vote down vote up
@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]));
		}

	}

}
 
Example #3
Source File: TestRetryListener.java    From seleniumtestsframework with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #4
Source File: RetryListener.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void transform(ITestAnnotation iTestAnnotation,
                      Class aClass, Constructor constructor, Method method) {
    Class<? extends IRetryAnalyzer> retry = iTestAnnotation.getRetryAnalyzerClass();
    if (retry == null) {
        iTestAnnotation.setRetryAnalyzer(Retry.class);
    }
}
 
Example #5
Source File: AbstractTestListener.java    From carina with Apache License 2.0 5 votes vote down vote up
private RetryAnalyzer getRetryAnalyzer(ITestResult result) {
    RetryAnalyzer retryAnalyzer = null;
    IRetryAnalyzer iRetry = result.getMethod().getRetryAnalyzer(result);
    if (iRetry instanceof RetryAnalyzer) {
        retryAnalyzer = (RetryAnalyzer) iRetry;
    }
    return retryAnalyzer;
}
 
Example #6
Source File: AbstractTestListener.java    From carina with Apache License 2.0 4 votes vote down vote up
@Override
public void onTestStart(ITestResult result) {
    LOGGER.debug("AbstractTestListener->onTestStart");
    VideoAnalyzer.disableVideoUpload();
    IRetryAnalyzer curRetryAnalyzer = getRetryAnalyzer(result);
    if (curRetryAnalyzer == null) {
        // Declare carina custom RetryAnalyzer annotation for each new test method. Handle use-case for data providers which has single method!
        // result.getMethod().setRetryAnalyzer(new RetryAnalyzer());
        result.getMethod().setRetryAnalyzerClass(RetryAnalyzer.class);
    } else {
        if (!(curRetryAnalyzer instanceof RetryAnalyzer)) {
            LOGGER.warn("Custom RetryAnalyzer is used: " + curRetryAnalyzer.getClass().getName());                
        }
        
    }
    
    generateParameters(result);

    if (!result.getTestContext().getCurrentXmlTest().getAllParameters()
            .containsKey(SpecialKeywords.EXCEL_DS_CUSTOM_PROVIDER) &&
            result.getParameters().length > 0) // set parameters from XLS only if test contains any parameter at
                                               // all)
    {
        if (result.getTestContext().getCurrentXmlTest().getAllParameters()
                .containsKey(SpecialKeywords.EXCEL_DS_ARGS)) {
            DSBean dsBean = new DSBean(result.getTestContext());
            int index = 0;
            for (String arg : dsBean.getArgs()) {
                dsBean.getTestParams().put(arg, (String) result.getParameters()[index++]);
            }
            result.getTestContext().getCurrentXmlTest().setParameters(dsBean.getTestParams());

        }
    }
    // obligatory reset any registered canonical name because for ALREADY_PASSED methods we can't do this in
    // onTestSkipped method
    // TestNamingUtil.releaseTestInfoByThread();

    startItem(result, Messager.TEST_STARTED);

}