use of io.cucumber.core.eventbus.EventBus in project cucumber-jvm by cucumber.
the class ThreadLocalRunnerSupplierTest method runner_should_wrap_event_bus_bus.
@Test
void runner_should_wrap_event_bus_bus() {
// This avoids problems with JUnit which listens to individual runners
EventBus runnerBus = runnerSupplier.get().getBus();
assertAll(() -> assertThat(eventBus, is(not(equalTo(runnerBus)))), () -> assertThat(runnerBus, is(not(equalTo(eventBus)))));
}
use of io.cucumber.core.eventbus.EventBus in project cucumber-jvm by cucumber.
the class JUnitReporterWithStepNotificationsTest method ignores_steps_when_step_notification_are_disabled.
@Test
void ignores_steps_when_step_notification_are_disabled() {
EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
JUnitReporter jUnitReporter = new JUnitReporter(bus, new JUnitOptionsBuilder().setStepNotifications(false).build());
jUnitReporter.startExecutionUnit(pickleRunner, runNotifier);
bus.send(new TestCaseStarted(now(), testCase));
bus.send(new TestStepStarted(now(), testCase, mockTestStep(step)));
Result result = new Result(Status.PASSED, ZERO, null);
bus.send(new TestStepFinished(now(), testCase, mockTestStep(step), result));
bus.send(new TestCaseFinished(now(), testCase, result));
verify(runNotifier, never()).fireTestStarted(pickleRunner.describeChild(step));
verify(runNotifier, never()).fireTestFinished(pickleRunner.describeChild(step));
}
use of io.cucumber.core.eventbus.EventBus 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);
}
use of io.cucumber.core.eventbus.EventBus in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_filter_pickles.
@Test
void should_filter_pickles() {
Feature feature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario_1 name\n" + " Given step #1\n" + " @tag\n" + " Scenario: scenario_2 name\n" + " Given step #1\n");
RuntimeOptions options = new RuntimeOptionsBuilder().addTagFilter(TagExpressionParser.parse("@tag")).build();
Filters filters = new Filters(options);
IllegalStateException illegalStateException = new IllegalStateException();
RunnerSupplier runnerSupplier = () -> {
throw illegalStateException;
};
EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
CucumberExecutionContext context = new CucumberExecutionContext(bus, new ExitStatus(options), runnerSupplier);
FeatureRunner featureRunner = FeatureRunner.create(feature, null, filters, context, new JUnitOptions());
assertThat(featureRunner.getChildren().size(), is(1));
assertThat(featureRunner.getChildren().get(0).getDescription().getDisplayName(), is("scenario_2 name(feature name)"));
}
use of io.cucumber.core.eventbus.EventBus in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method createFeatureRunner.
private FeatureRunner createFeatureRunner(Feature feature, JUnitOptions junitOption) {
ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(getClass()::getClassLoader, RuntimeOptions.defaultOptions());
ObjectFactorySupplier objectFactory = new SingletonObjectFactorySupplier(objectFactoryServiceLoader);
final RuntimeOptions runtimeOptions = RuntimeOptions.defaultOptions();
final Clock clockStub = new Clock() {
@Override
public ZoneId getZone() {
return null;
}
@Override
public Clock withZone(ZoneId zone) {
return null;
}
@Override
public Instant instant() {
return Instant.EPOCH;
}
};
BackendSupplier backendSupplier = () -> singleton(new StubBackendProviderService.StubBackend());
EventBus bus = new TimeServiceEventBus(clockStub, UUID::randomUUID);
Filters filters = new Filters(runtimeOptions);
ThreadLocalRunnerSupplier runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, bus, backendSupplier, objectFactory);
CucumberExecutionContext context = new CucumberExecutionContext(bus, new ExitStatus(runtimeOptions), runnerSupplier);
return FeatureRunner.create(feature, null, filters, context, junitOption);
}
Aggregations