io.cucumber.junit.CucumberOptions Java Examples

The following examples show how to use io.cucumber.junit.CucumberOptions. 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: Context.java    From NoraUi with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Gets all Cucumber methods.
 *
 * @param clazz
 *            Class which is the main point of the application (Decorated with the annotation {@link io.cucumber.junit.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.
 */
private static Map<String, Method> getAllCucumberMethods(Class<?> clazz) {
    final CucumberOptions co = clazz.getAnnotation(CucumberOptions.class);
    final Set<Class<?>> classes = getClasses(co.glue());
    classes.add(BrowserSteps.class);
    //@formatter:off
    return classes.stream() //
           .flatMap(c -> Arrays.stream(c.getDeclaredMethods())) //
           .flatMap(m -> Arrays.stream(m.getAnnotations()) //
           .filter(stepAnnotation -> stepAnnotation.annotationType().isAnnotationPresent(StepDefAnnotation.class)) //
           .map(ann -> {
             try {
               return new AbstractMap.SimpleEntry<>(ann.annotationType().getDeclaredMethod("value").invoke(ann).toString(), m);
             } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
             }
             return null;
             })) //
           .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); //
    //@formatter:on
}
 
Example #2
Source File: CucumberTestUnitFinder.java    From pitest-cucumber-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public CucumberOptionsAnnotationParser.CucumberOptions getOptions(Class<?> clazz) {
    // this is ok since up to Cucumber 4.7.1, il will fallback on cucumber.api.CucumberOptions
    // @see io.cucumber.core.options.CucumberOptionsAnnotationParser (l.41)
    final io.cucumber.junit.CucumberOptions annotation = clazz.getAnnotation(io.cucumber.junit.CucumberOptions.class);
    if (annotation == null) {
        return null;
    }
    return new CustomCucumberOptions(annotation);
}
 
Example #3
Source File: CucumberTestUnitFinder.java    From pitest-cucumber-plugin with Apache License 2.0 4 votes vote down vote up
public CustomCucumberOptions(CucumberOptions annotation) {
    this.annotation = annotation;
}