Search in sources :

Example 6 with Plugins

use of io.cucumber.core.plugin.Plugins in project cucumber-jvm by cucumber.

the class CommandlineOptionsParserTest method set_strict_on_strict_aware_formatters.

@Test
void set_strict_on_strict_aware_formatters() {
    RuntimeOptions options = parser.parse("--plugin", AwareFormatter.class.getName()).build();
    Plugins plugins = new Plugins(new PluginFactory(), options);
    plugins.setEventBusOnEventListenerPlugins(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));
    AwareFormatter formatter = (AwareFormatter) plugins.getPlugins().get(0);
    assertThat(formatter.isStrict(), is(true));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) PluginFactory(io.cucumber.core.plugin.PluginFactory) Plugins(io.cucumber.core.plugin.Plugins) Test(org.junit.jupiter.api.Test)

Example 7 with Plugins

use of io.cucumber.core.plugin.Plugins in project cucumber-jvm by cucumber.

the class CucumberOptionsAnnotationParserTest method create_without_options_with_base_class_without_options.

@Test
void create_without_options_with_base_class_without_options() {
    Class<?> subClassWithMonoChromeTrueClass = WithoutOptionsWithBaseClassWithoutOptions.class;
    RuntimeOptions runtimeOptions = parser().parse(subClassWithMonoChromeTrueClass).build();
    Plugins plugins = new Plugins(new PluginFactory(), runtimeOptions);
    plugins.setEventBusOnEventListenerPlugins(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));
    assertAll(() -> assertThat(runtimeOptions.getFeaturePaths(), contains(uri("classpath:/io/cucumber/core/options"))), () -> assertThat(runtimeOptions.getGlue(), contains(uri("classpath:/io/cucumber/core/options"))), () -> assertThat(plugins.getPlugins(), is(empty())));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) PluginFactory(io.cucumber.core.plugin.PluginFactory) Plugins(io.cucumber.core.plugin.Plugins) Test(org.junit.jupiter.api.Test)

Example 8 with Plugins

use of io.cucumber.core.plugin.Plugins in project cucumber-jvm by cucumber.

the class CucumberOptionsAnnotationParserTest method create_without_options.

@Test
void create_without_options() {
    RuntimeOptions runtimeOptions = parser().parse(WithoutOptions.class).build();
    assertAll(() -> assertThat(runtimeOptions.getObjectFactoryClass(), is(nullValue())), () -> assertThat(runtimeOptions.getFeaturePaths(), contains(uri("classpath:/io/cucumber/core/options"))), () -> assertThat(runtimeOptions.getGlue(), contains(uri("classpath:/io/cucumber/core/options"))));
    Plugins plugins = new Plugins(new PluginFactory(), runtimeOptions);
    plugins.setEventBusOnEventListenerPlugins(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));
    assertAll(() -> assertThat(plugins.getPlugins(), is(empty())));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) PluginFactory(io.cucumber.core.plugin.PluginFactory) Plugins(io.cucumber.core.plugin.Plugins) Test(org.junit.jupiter.api.Test)

Example 9 with Plugins

use of io.cucumber.core.plugin.Plugins in project cucumber-jvm by cucumber.

the class CucumberEngineExecutionContext method createCucumberExecutionContext.

private CucumberExecutionContext createCucumberExecutionContext() {
    Supplier<ClassLoader> classLoader = CucumberEngineExecutionContext.class::getClassLoader;
    ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(classLoader, options);
    EventBus bus = synchronize(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));
    Plugins plugins = new Plugins(new PluginFactory(), options);
    ExitStatus exitStatus = new ExitStatus(options);
    plugins.addPlugin(exitStatus);
    RunnerSupplier runnerSupplier;
    if (options.isParallelExecutionEnabled()) {
        plugins.setSerialEventBusOnEventListenerPlugins(bus);
        ObjectFactorySupplier objectFactorySupplier = new ThreadLocalObjectFactorySupplier(objectFactoryServiceLoader);
        BackendSupplier backendSupplier = new BackendServiceLoader(classLoader, objectFactorySupplier);
        runnerSupplier = new ThreadLocalRunnerSupplier(options, bus, backendSupplier, objectFactorySupplier);
    } else {
        plugins.setEventBusOnEventListenerPlugins(bus);
        ObjectFactorySupplier objectFactorySupplier = new SingletonObjectFactorySupplier(objectFactoryServiceLoader);
        BackendSupplier backendSupplier = new BackendServiceLoader(classLoader, objectFactorySupplier);
        runnerSupplier = new SingletonRunnerSupplier(options, bus, backendSupplier, objectFactorySupplier);
    }
    return new CucumberExecutionContext(bus, exitStatus, runnerSupplier);
}
Also used : BackendSupplier(io.cucumber.core.runtime.BackendSupplier) ObjectFactoryServiceLoader(io.cucumber.core.runtime.ObjectFactoryServiceLoader) SingletonRunnerSupplier(io.cucumber.core.runtime.SingletonRunnerSupplier) SingletonObjectFactorySupplier(io.cucumber.core.runtime.SingletonObjectFactorySupplier) ThreadLocalObjectFactorySupplier(io.cucumber.core.runtime.ThreadLocalObjectFactorySupplier) EventBus(io.cucumber.core.eventbus.EventBus) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) ExitStatus(io.cucumber.core.runtime.ExitStatus) ThreadLocalRunnerSupplier(io.cucumber.core.runtime.ThreadLocalRunnerSupplier) CucumberExecutionContext(io.cucumber.core.runtime.CucumberExecutionContext) SingletonRunnerSupplier(io.cucumber.core.runtime.SingletonRunnerSupplier) RunnerSupplier(io.cucumber.core.runtime.RunnerSupplier) ThreadLocalRunnerSupplier(io.cucumber.core.runtime.ThreadLocalRunnerSupplier) BackendServiceLoader(io.cucumber.core.runtime.BackendServiceLoader) PluginFactory(io.cucumber.core.plugin.PluginFactory) SingletonObjectFactorySupplier(io.cucumber.core.runtime.SingletonObjectFactorySupplier) ObjectFactorySupplier(io.cucumber.core.runtime.ObjectFactorySupplier) ThreadLocalObjectFactorySupplier(io.cucumber.core.runtime.ThreadLocalObjectFactorySupplier) Plugins(io.cucumber.core.plugin.Plugins)

Example 10 with Plugins

use of io.cucumber.core.plugin.Plugins in project cucumber-jvm by cucumber.

the class CommandlineOptionsParserTest method creates_default_summary_printer_for_deprecated_default_summary_argument.

@Test
void creates_default_summary_printer_for_deprecated_default_summary_argument() {
    RuntimeOptions options = parser.parse("--plugin default_summary").addDefaultSummaryPrinterIfNotDisabled().build();
    Plugins plugins = new Plugins(new PluginFactory(), options);
    plugins.setEventBusOnEventListenerPlugins(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));
    assertThat(plugins.getPlugins(), hasItem(plugin("io.cucumber.core.plugin.DefaultSummaryPrinter")));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) PluginFactory(io.cucumber.core.plugin.PluginFactory) Plugins(io.cucumber.core.plugin.Plugins) Test(org.junit.jupiter.api.Test)

Aggregations

PluginFactory (io.cucumber.core.plugin.PluginFactory)13 Plugins (io.cucumber.core.plugin.Plugins)13 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)13 Test (org.junit.jupiter.api.Test)12 EventBus (io.cucumber.core.eventbus.EventBus)1 BackendServiceLoader (io.cucumber.core.runtime.BackendServiceLoader)1 BackendSupplier (io.cucumber.core.runtime.BackendSupplier)1 CucumberExecutionContext (io.cucumber.core.runtime.CucumberExecutionContext)1 ExitStatus (io.cucumber.core.runtime.ExitStatus)1 ObjectFactoryServiceLoader (io.cucumber.core.runtime.ObjectFactoryServiceLoader)1 ObjectFactorySupplier (io.cucumber.core.runtime.ObjectFactorySupplier)1 RunnerSupplier (io.cucumber.core.runtime.RunnerSupplier)1 SingletonObjectFactorySupplier (io.cucumber.core.runtime.SingletonObjectFactorySupplier)1 SingletonRunnerSupplier (io.cucumber.core.runtime.SingletonRunnerSupplier)1 ThreadLocalObjectFactorySupplier (io.cucumber.core.runtime.ThreadLocalObjectFactorySupplier)1 ThreadLocalRunnerSupplier (io.cucumber.core.runtime.ThreadLocalRunnerSupplier)1 Plugin (io.cucumber.plugin.Plugin)1