use of io.cucumber.core.runtime.RunnerSupplier in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_notify_of_failure_to_create_runners_and_request_test_execution_to_stop.
@Test
void should_notify_of_failure_to_create_runners_and_request_test_execution_to_stop() {
Feature feature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario_1 name\n" + " Given step #1\n");
Filters filters = new Filters(RuntimeOptions.defaultOptions());
IllegalStateException illegalStateException = new IllegalStateException();
RunnerSupplier runnerSupplier = () -> {
throw illegalStateException;
};
TimeServiceEventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
RuntimeOptions options = RuntimeOptions.defaultOptions();
CucumberExecutionContext context = new CucumberExecutionContext(bus, new ExitStatus(options), runnerSupplier);
FeatureRunner featureRunner = FeatureRunner.create(feature, null, filters, context, new JUnitOptions());
RunNotifier notifier = mock(RunNotifier.class);
PickleRunners.PickleRunner pickleRunner = featureRunner.getChildren().get(0);
featureRunner.runChild(pickleRunner, notifier);
Description description = pickleRunner.getDescription();
ArgumentCaptor<Failure> failureArgumentCaptor = ArgumentCaptor.forClass(Failure.class);
InOrder order = inOrder(notifier);
order.verify(notifier).fireTestStarted(description);
order.verify(notifier).fireTestFailure(failureArgumentCaptor.capture());
assertThat(failureArgumentCaptor.getValue().getException(), is(equalTo(illegalStateException)));
assertThat(failureArgumentCaptor.getValue().getDescription(), is(equalTo(description)));
order.verify(notifier).pleaseStop();
order.verify(notifier).fireTestFinished(description);
}
use of io.cucumber.core.runtime.RunnerSupplier 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.runtime.RunnerSupplier 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)"));
}
Aggregations