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


Java StepDefAnnotation类代码示例

本文整理汇总了Java中cucumber.runtime.java.StepDefAnnotation的典型用法代码示例。如果您正苦于以下问题:Java StepDefAnnotation类的具体用法?Java StepDefAnnotation怎么用?Java StepDefAnnotation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getAllCucumberMethods

import cucumber.runtime.java.StepDefAnnotation; //导入依赖的package包/类
/**
 * Gets all Cucumber methods.
 *
 * @param clazz
 *            Class which is the main point of the application (Decorated with the annotation {@link cucumber.api.CucumberOptions})
 * @return a Map of all Cucumber glue code methods of the application. First part of the entry is the Gherkin matching regular expression.
 *         Second part is the corresponding invokable method.
 */
public static Map<String, Method> getAllCucumberMethods(Class<?> clazz) {
    Map<String, Method> result = new HashMap<>();
    CucumberOptions co = clazz.getAnnotation(CucumberOptions.class);
    Set<Class<?>> classes = getClasses(co.glue());
    classes.add(BrowserSteps.class);

    for (Class<?> c : classes) {
        Method[] methods = c.getDeclaredMethods();
        for (Method method : methods) {
            for (Annotation stepAnnotation : method.getAnnotations()) {
                if (stepAnnotation.annotationType().isAnnotationPresent(StepDefAnnotation.class)) {
                    result.put(stepAnnotation.toString(), method);
                }
            }
        }
    }
    return result;
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:27,代码来源:Step.java

示例2: isStepDefinitionAnnotation

import cucumber.runtime.java.StepDefAnnotation; //导入依赖的package包/类
private boolean isStepDefinitionAnnotation(Annotation annotation) {
  Class annotationType = annotation.annotationType();
  return annotationType.getAnnotation(StepDefAnnotation.class) != null;
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:5,代码来源:TestObjectTypeListener.java

示例3: generateDocumentation

import cucumber.runtime.java.StepDefAnnotation; //导入依赖的package包/类
public void generateDocumentation() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException {
		
	
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.addUrls(SenBotContext.class.getProtectionDomain().getCodeSource().getLocation());

    cb.addUrls(When.class.getProtectionDomain().getCodeSource().getLocation());
    Reflections cucumberStepDefReflections = new Reflections(cb);
	
	
	Set<Class<?>> allCucumberStepMethodAnnotations = cucumberStepDefReflections.getTypesAnnotatedWith(StepDefAnnotation.class);
	
	for(Class parentClass : allCucumberStepMethodAnnotations) {
		if(parentClass.toString().contains("cucumber.api.java")) {
			//it's a given/when/then/and/but annotation
			continue;
		}
		else {
			Method[] allMethods = parentClass.getMethods();
			for(Method m : allMethods) {					
				Annotation[] annotations = m.getAnnotations();
				for(Annotation an : annotations) {
					if(an.toString().contains("cucumber.api.java")) {
						
						Method valueFetcher = an.getClass().getMethod("value");
						Object invoke = valueFetcher.invoke(an);
						if(invoke instanceof String) {
							StepDef stepDef = new StepDef(parentClass, m, an);
							
							availableStepDefs.put(stepDef.getStepRegexValue(), stepDef);
						}
						else {
							// if the Annotation argument is not just a string it won't be a @When, @Then, @Given, @And, @But
							// most likeley it will be a @Before @After
						}
					}
				}
			}
		}
	}
}
 
开发者ID:gfk-ba,项目名称:senbot,代码行数:42,代码来源:SenBotDocumenter.java

示例4: isStepdefAnnotation

import cucumber.runtime.java.StepDefAnnotation; //导入依赖的package包/类
private boolean isStepdefAnnotation(Annotation annotation) {
    Class<? extends Annotation> annotationClass = annotation.annotationType();
    return annotationClass.getAnnotation(StepDefAnnotation.class) != null;
}
 
开发者ID:mfellner,项目名称:cucumber-android,代码行数:5,代码来源:AndroidClasspathMethodScanner.java


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