当前位置: 首页>>代码示例>>Java>>正文


Java ITestNGMethod.getRealClass方法代码示例

本文整理汇总了Java中org.testng.ITestNGMethod.getRealClass方法的典型用法代码示例。如果您正苦于以下问题:Java ITestNGMethod.getRealClass方法的具体用法?Java ITestNGMethod.getRealClass怎么用?Java ITestNGMethod.getRealClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.testng.ITestNGMethod的用法示例。


在下文中一共展示了ITestNGMethod.getRealClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeClassLevel

import org.testng.ITestNGMethod; //导入方法依赖的package包/类
private void initializeClassLevel(ITestContext iTestContext) {
    classBrowsers.clear();
    ITestNGMethod[] testMethods = iTestContext.getAllTestMethods();
    for (ITestNGMethod method : testMethods) {
        Class<?> testClass = method.getRealClass();
        for (Field field : ReflectionUtils.getAllFieldsOfClassHierarchy(testClass)) {
            boolean fieldIsStatic = Modifier.isStatic(field.getModifiers());
            boolean fieldIsABrowser = Browser.class.isAssignableFrom(field.getType());
            boolean fieldIsAnnotatedAsResource = field.getAnnotation(Resource.class) != null;
            boolean isNoDuplicate = fieldIsNoDuplicateOfAnExistingClassBrowserField(field);
            if (fieldIsStatic && fieldIsABrowser && fieldIsAnnotatedAsResource && isNoDuplicate) {
                classBrowserFields.add(field);
                classBrowsers.add(new ClassTestBrowser(field));
            }
        }
    }
}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:18,代码来源:WebTesterTestNGListener.java

示例2: getParametersForMethod

import org.testng.ITestNGMethod; //导入方法依赖的package包/类
/**
 * Obtains list of parameter sets for test method based on defined data provider.
 * If no data provider is defined then {@link Optional#empty()} is returned.
 * This method takes into consideration only data providers defined through annotation.
 *
 * @param method to be examined
 * @return list of parameter sets
 */
public static Optional<Object[][]> getParametersForMethod(ITestNGMethod method)
{
    Test testAnnotation = method.getConstructorOrMethod().getMethod().getAnnotation(Test.class);
    Class dataProviderClass = testAnnotation.dataProviderClass();
    if (dataProviderClass == null || dataProviderClass == Object.class) {
        dataProviderClass = method.getRealClass();
    }
    String dataProviderName = testAnnotation.dataProvider();
    if (dataProviderName.isEmpty()) {
        return Optional.empty();
    }

    Optional<Method> dataProviderMethodOptional = asList(dataProviderClass.getMethods()).stream().filter(
            m -> {
                DataProvider annotation = m.getAnnotation(DataProvider.class);
                return annotation != null && annotation.name().equals(dataProviderName);
            }
    ).findFirst();
    if (dataProviderMethodOptional.isPresent()) {
        try {
            return Optional.of((Object[][]) dataProviderMethodOptional.get().invoke(null));
        }
        catch (Exception e) {
            throw new RuntimeException("Exception while calling data provider for " + method, e);
        }
    }
    else {
        return Optional.empty();
    }
}
 
开发者ID:prestodb,项目名称:tempto,代码行数:39,代码来源:DataProviders.java

示例3: injectConfigurationValuesIntoStaticFields

import org.testng.ITestNGMethod; //导入方法依赖的package包/类
private void injectConfigurationValuesIntoStaticFields(ITestContext iTestContext) {
    ITestNGMethod[] testMethods = iTestContext.getAllTestMethods();
    for (ITestNGMethod method : testMethods) {
        Class<?> testClass = method.getRealClass();
        if (configurationValuesAnnotationIsUsedOnClassLevel(testClass)) {
            Configuration configuration = getPrimaryBrowser().getBrowser().getConfiguration();
            ConfigurationValueInjector.injectStatics(configuration, testClass);
        }
    }
}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:11,代码来源:WebTesterTestNGListener.java


注:本文中的org.testng.ITestNGMethod.getRealClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。