use of io.cucumber.core.options.RuntimeOptions in project cucumber-jvm by cucumber.
the class RunnerTest method hooks_not_executed_in_dry_run_mode.
@Test
void hooks_not_executed_in_dry_run_mode() {
RuntimeOptions runtimeOptions = new RuntimeOptionsBuilder().setDryRun().build();
StaticHookDefinition beforeAllHook = createStaticHook();
StaticHookDefinition afterAllHook = createStaticHook();
HookDefinition beforeHook = createHook();
HookDefinition afterHook = createHook();
HookDefinition beforeStepHook = createHook();
HookDefinition afterStepHook = createHook();
TestRunnerSupplier runnerSupplier = new TestRunnerSupplier(bus, runtimeOptions) {
@Override
public void loadGlue(Glue glue, List<URI> gluePaths) {
glue.addBeforeAllHook(beforeAllHook);
glue.addAfterAllHook(afterAllHook);
glue.addBeforeHook(beforeHook);
glue.addAfterHook(afterHook);
glue.addBeforeStepHook(beforeStepHook);
glue.addAfterStepHook(afterStepHook);
}
};
runnerSupplier.get().runBeforeAllHooks();
runnerSupplier.get().runPickle(createPicklesWithSteps());
runnerSupplier.get().runAfterAllHooks();
verify(beforeAllHook, never()).execute();
verify(afterAllHook, never()).execute();
verify(beforeHook, never()).execute(any(TestCaseState.class));
verify(afterHook, never()).execute(any(TestCaseState.class));
verify(beforeStepHook, never()).execute(any(TestCaseState.class));
verify(afterStepHook, never()).execute(any(TestCaseState.class));
}
use of io.cucumber.core.options.RuntimeOptions in project cucumber-jvm by cucumber.
the class RunnerTest method steps_are_not_executed_on_dry_run.
@Test
void steps_are_not_executed_on_dry_run() {
StubStepDefinition stepDefinition = new StubStepDefinition("some step");
Pickle pickle = createPickleMatchingStepDefinitions(stepDefinition);
RuntimeOptions runtimeOptions = new RuntimeOptionsBuilder().setDryRun().build();
TestRunnerSupplier runnerSupplier = new TestRunnerSupplier(bus, runtimeOptions) {
@Override
public void loadGlue(Glue glue, List<URI> gluePaths) {
glue.addStepDefinition(stepDefinition);
}
};
runnerSupplier.get().runPickle(pickle);
assertThat(stepDefinition.getArgs(), is(nullValue()));
}
use of io.cucumber.core.options.RuntimeOptions 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.options.RuntimeOptions 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);
}
use of io.cucumber.core.options.RuntimeOptions in project cucumber-jvm by cucumber.
the class PluginsTest method shouldSetConcurrentEventListener.
@Test
void shouldSetConcurrentEventListener() {
RuntimeOptions runtimeOptions = RuntimeOptions.defaultOptions();
Plugins plugins = new Plugins(pluginFactory, runtimeOptions);
ConcurrentEventListener plugin = mock(ConcurrentEventListener.class);
plugins.addPlugin(plugin);
plugins.setEventBusOnEventListenerPlugins(rootEventPublisher);
verify(plugin, times(1)).setEventPublisher(rootEventPublisher);
}
Aggregations