org.testng.annotations.ITestAnnotation Java Examples
The following examples show how to use
org.testng.annotations.ITestAnnotation.
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: DataProviderUtil.java From qaf with MIT License | 6 votes |
public static void setQAFDataProvider(ITestAnnotation testAnnotation, Method method) { if ((null != method) && null != method.getParameterTypes() && (method.getParameterTypes().length > 0)) { String dataProvider = testAnnotation.getDataProvider(); boolean hasDataProvider = isNotBlank(dataProvider); // other than qaf data provider if (hasDataProvider && !dataProvider.startsWith(QAFDataProvider.NAME)) { // keep actual data-provider details with description Map<String, String> desc = new HashMap<String, String>(); desc.put("description", testAnnotation.getDescription()); desc.put("dataProvider", testAnnotation.getDataProvider()); Class<?> dpClass = testAnnotation.getDataProviderClass(); if (null != dpClass) { desc.put("dataProviderClass", dpClass.getName()); } testAnnotation.setDescription(new JSONObject(desc).toString()); } boolean globalParallelSetting = getBundle().getBoolean("global.datadriven.parallel", false); boolean parallel = getBundle().getBoolean(method.getName() + ".parallel", globalParallelSetting); dataProvider = parallel ? QAFDataProvider.NAME_PARALLEL : QAFDataProvider.NAME; testAnnotation.setDataProvider(dataProvider); testAnnotation.setDataProviderClass(QAFInetrceptableDataProvider.class); } }
Example #2
Source File: DisableOnWindowsListener.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Override public void transform( final ITestAnnotation annotation, final Class testClass, final Constructor testConstructor, final Method testMethod ) { if (testMethod != null ) { final DisableOnWindows disableOnWindows = testMethod.getAnnotation(DisableOnWindows.class); if (disableOnWindows != null && Os.isMicrosoftWindows()) { annotation.setEnabled(false); LOG.info(String.format("Disabled: %s.%s - %s", testMethod.getDeclaringClass().getName(), testMethod.getName(), disableOnWindows.reason())); } } }
Example #3
Source File: FailRetryAnnotationTransformer.java From agent with MIT License | 5 votes |
@Override public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) { Class retry = annotation.getRetryAnalyzerClass(); if (retry != FailRetryAnalyzer.class) { annotation.setRetryAnalyzer(FailRetryAnalyzer.class); } }
Example #4
Source File: RetryListener.java From gsc-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void transform(ITestAnnotation testannotation, Class testClass, Constructor testConstructor, Method testMethod) { IRetryAnalyzer retry = testannotation.getRetryAnalyzer(); if (retry == null) { testannotation.setRetryAnalyzer(Retry.class); } }
Example #5
Source File: RetryListener.java From WebAndAppUITesting with GNU General Public License v3.0 | 5 votes |
@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 #6
Source File: DependencyRemovalTransformer.java From ats-framework with Apache License 2.0 | 5 votes |
public void transform( ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod ) { annotation.setDependsOnMethods(null); annotation.setDependsOnGroups(null); }
Example #7
Source File: MethodHelper.java From qaf with MIT License | 5 votes |
protected static boolean isEnabled(Method m, IAnnotationFinder finder) { ITestAnnotation annotation = AnnotationHelper.findTest(finder, m); // If no method annotation, look for one on the class if (null == annotation) { annotation = AnnotationHelper.findTest(finder, m.getDeclaringClass()); } return isEnabled(annotation); }
Example #8
Source File: AnnotationListener.java From pulsar with Apache License 2.0 | 5 votes |
@Override public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) { annotation.setRetryAnalyzer(RetryAnalyzer.class); // Enforce default test timeout if (annotation.getTimeOut() == 0) { annotation.setTimeOut(DEFAULT_TEST_TIMEOUT_MILLIS); } }
Example #9
Source File: TestRetryListener.java From seleniumtestsframework with Apache License 2.0 | 5 votes |
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 #10
Source File: RetryListener.java From AppiumTestDistribution with GNU General Public License v3.0 | 5 votes |
@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 #11
Source File: TestNGRunner.java From buck with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("rawtypes") public void transform( ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) { if (testMethod == null) { return; } String className = testMethod.getDeclaringClass().getName(); String methodName = testMethod.getName(); TestDescription description = new TestDescription(className, methodName); TestSelector matchingSelector = testSelectorList.findSelector(description); if (!matchingSelector.isInclusive()) { // For tests that have been filtered out, record it now and don't run it if (shouldExplainTestSelectors) { String reason = "Excluded by filter: " + matchingSelector.getExplanation(); results.add(TestResult.forExcluded(className, methodName, reason)); } annotation.setEnabled(false); return; } if (!annotation.getEnabled()) { // on a dry run, have to record it now -- since it doesn't run, listener can't do it results.add(TestResult.forDisabled(className, methodName)); return; } if (isDryRun) { // on a dry run, record it now and don't run it results.add(TestResult.forDryRun(className, methodName)); annotation.setEnabled(false); return; } }
Example #12
Source File: MethodHelper.java From qaf with MIT License | 4 votes |
protected static boolean isEnabled(Class<?> objectClass, IAnnotationFinder finder) { ITestAnnotation testClassAnnotation = AnnotationHelper.findTest(finder, objectClass); return isEnabled(testClassAnnotation); }
Example #13
Source File: OnpremSeleniumTestHandler.java From codenvy with Eclipse Public License 1.0 | 4 votes |
@Override public void transform( ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {}
Example #14
Source File: SeleniumTestHandler.java From che with Eclipse Public License 2.0 | 4 votes |
@Override public void transform( ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) { testFilter.excludeTestOfImproperGroup(annotation); }