Search in sources :

Example 1 with CucumberOptions

use of cucumber.api.CucumberOptions in project cucumber-jvm by cucumber.

the class RuntimeOptionsFactory method buildArgsFromOptions.

private List<String> buildArgsFromOptions() {
    List<String> args = new ArrayList<String>();
    for (Class classWithOptions = clazz; hasSuperClass(classWithOptions); classWithOptions = classWithOptions.getSuperclass()) {
        CucumberOptions options = getOptions(classWithOptions);
        if (options != null) {
            addDryRun(options, args);
            addMonochrome(options, args);
            addTags(options, args);
            addPlugins(options, args);
            addStrict(options, args);
            addName(options, args);
            addSnippets(options, args);
            addGlue(options, args);
            addFeatures(options, args);
            addJunitOptions(options, args);
        }
    }
    addDefaultFeaturePathIfNoFeaturePathIsSpecified(args, clazz);
    addDefaultGlueIfNoGlueIsSpecified(args, clazz);
    addNullFormatIfNoPluginIsSpecified(args);
    return args;
}
Also used : CucumberOptions(cucumber.api.CucumberOptions) ArrayList(java.util.ArrayList)

Example 2 with CucumberOptions

use of cucumber.api.CucumberOptions in project NoraUi by NoraUi.

the class Step method getAllCucumberMethods.

/**
 * 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) {
    final Map<String, Method> result = new HashMap<>();
    final CucumberOptions co = clazz.getAnnotation(CucumberOptions.class);
    final Set<Class<?>> classes = getClasses(co.glue());
    classes.add(BrowserSteps.class);
    for (final Class<?> c : classes) {
        final Method[] methods = c.getDeclaredMethods();
        for (final Method method : methods) {
            for (final Annotation stepAnnotation : method.getAnnotations()) {
                if (stepAnnotation.annotationType().isAnnotationPresent(StepDefAnnotation.class)) {
                    result.put(stepAnnotation.toString(), method);
                }
            }
        }
    }
    return result;
}
Also used : CucumberOptions(cucumber.api.CucumberOptions) HashMap(java.util.HashMap) Method(java.lang.reflect.Method) StepDefAnnotation(cucumber.runtime.java.StepDefAnnotation) Annotation(java.lang.annotation.Annotation)

Aggregations

CucumberOptions (cucumber.api.CucumberOptions)2 StepDefAnnotation (cucumber.runtime.java.StepDefAnnotation)1 Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1