io.cucumber.core.eventbus.EventBus Java Examples

The following examples show how to use io.cucumber.core.eventbus.EventBus. 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: AllureCucumber5JvmTest.java    From allure-java with Apache License 2.0 7 votes vote down vote up
private byte runFeature(final AllureResultsWriterStub writer,
                        final String featureResource,
                        final String... moreOptions) {

    final AllureLifecycle lifecycle = new AllureLifecycle(writer);
    final AllureCucumber5Jvm cucumber5Jvm = new AllureCucumber5Jvm(lifecycle);
    Supplier<ClassLoader> classLoader = ClassLoaders::getDefaultClassLoader;
    final List<String> opts = new ArrayList<>(Arrays.asList(
            "--glue", "io.qameta.allure.cucumber5jvm.samples",
            "--plugin", "null_summary"
    ));
    opts.addAll(Arrays.asList(moreOptions));
    FeatureWithLines featureWithLines = FeatureWithLines.parse("src/test/resources/"+featureResource);
    final RuntimeOptions options = new CommandlineOptionsParser().parse(opts).addFeature(featureWithLines).build();
    boolean mt = options.isMultiThreaded();

    EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
    FeatureParser parser = new FeatureParser(bus::generateId);
    FeaturePathFeatureSupplier supplier = new FeaturePathFeatureSupplier(classLoader, options, parser);

    final Runtime runtime = Runtime.builder()
            .withClassLoader(classLoader)
            .withRuntimeOptions(options)
            .withAdditionalPlugins(cucumber5Jvm)
            .withFeatureSupplier(supplier)
            .build();

    runtime.run();
    return runtime.exitStatus();
}
 
Example #2
Source File: CucumberRuntime.java    From cucumber-performance with MIT License 6 votes vote down vote up
private CucumberRuntime(final ExitStatus exitStatus,
                final EventBus bus,
                final Predicate<Pickle> filter,
                final int limit,
                final RunnerSupplier runnerSupplier,
                final List<Feature> features,
                final ExecutorService executor,
                final PickleOrder pickleOrder,
                final boolean failFast) {
    this.bus = bus;
    this.filter = filter;
    this.limit = limit;
    this.runnerSupplier = runnerSupplier;
    //this.featureSupplier = featureSupplier;
    this.features = features;
    this.executor = executor;
    this.exitStatus = exitStatus;
    this.pickleOrder = pickleOrder;
    this.failFast = failFast;
}
 
Example #3
Source File: CourgetteLoader.java    From courgette-jvm with MIT License 5 votes vote down vote up
public CourgetteLoader(CourgetteProperties courgetteProperties) {
    this.courgetteProperties = courgetteProperties;

    RuntimeOptions runtimeOptions = createRuntimeOptions();
    this.filters = new Filters(runtimeOptions);

    EventBus eventBus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
    FeatureParser parser = new FeatureParser(eventBus::generateId);
    Supplier<ClassLoader> classLoader = ClassLoaders::getDefaultClassLoader;
    FeaturePathFeatureSupplier featureSupplier = new FeaturePathFeatureSupplier(classLoader, runtimeOptions, parser);

    this.features = featureSupplier.get();
}
 
Example #4
Source File: PerfPlan.java    From cucumber-performance with MIT License 4 votes vote down vote up
public void sendTestSourceRead(EventBus bus) {
    bus.send(new TestSourceRead(bus.getInstant(), uri, saladSource));
}
 
Example #5
Source File: CucumberRuntime.java    From cucumber-performance with MIT License 4 votes vote down vote up
public Builder withEventBus(final EventBus eventBus) {
    this.eventBus = eventBus;
    return this;
}
 
Example #6
Source File: ScenarioTestUnit.java    From pitest-cucumber-plugin with Apache License 2.0 4 votes vote down vote up
public ScenarioTestUnit(Description description, Pickle scenario, RunnerSupplier runnerSupplier, EventBus eventBus) {
    this.description = description;
    this.scenario = scenario;
    this.runnerSupplier = runnerSupplier;
    this.eventBus = eventBus;
}
 
Example #7
Source File: CucumberTestUnitFinder.java    From pitest-cucumber-plugin with Apache License 2.0 4 votes vote down vote up
public List<TestUnit> findTestUnits(Class<?> junitTestClass) {

        if (hasACucumberAnnotation(junitTestClass)) {

            List<TestUnit> result = new ArrayList<>();

            RuntimeOptions runtimeOptions = new CucumberOptionsAnnotationParser()
                .withOptionsProvider(new CustomProvider())
                .parse(junitTestClass)
                .build();

            TimeServiceEventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
            FeatureParser parser = new FeatureParser(bus::generateId);

            FeatureSupplier featureSupplier = new FeaturePathFeatureSupplier(junitTestClass::getClassLoader, runtimeOptions, parser);
            final List<Feature> cucumberFeatures = featureSupplier.get();
            final Filters filters = new Filters(runtimeOptions);
            EventBus eventBus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
            ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(runtimeOptions);
            ObjectFactorySupplier objectFactorySupplier = new ThreadLocalObjectFactorySupplier(objectFactoryServiceLoader);
            BackendSupplier backendSupplier = new BackendServiceLoader(junitTestClass::getClassLoader, objectFactorySupplier);
            TypeRegistryConfigurerSupplier typeRegistryConfigurerSupplier = new ScanningTypeRegistryConfigurerSupplier(junitTestClass::getClassLoader, runtimeOptions);
            RunnerSupplier runnerSupplier = new SingletonRunnerSupplier(runtimeOptions, eventBus, backendSupplier, objectFactorySupplier, typeRegistryConfigurerSupplier);
            for (Feature feature : cucumberFeatures) {
                Log.getLogger().fine("Found feature \"" + feature.getName() + "\"");
                List<Pickle> pickles = feature.getPickles();
                for (Pickle pickle : pickles) {
                    if (!filters.test(pickle)) continue;
                    Description description = new Description(
                        feature.getName() + " : " + pickle.getName(),
                        junitTestClass);
                    Log.getLogger().fine("Found \"" + description.getName() + "\"");
                    result.add(new ScenarioTestUnit(description, pickle, runnerSupplier, eventBus));
                }
            }

            return result;

        }

        return Collections.emptyList();
    }