use of io.cucumber.core.options.RuntimeOptions in project cucumber-jvm by cucumber.
the class ThreadLocalRunnerSupplierTest method before.
@BeforeEach
void before() {
Supplier<ClassLoader> classLoader = ThreadLocalRunnerSupplierTest.class::getClassLoader;
RuntimeOptions runtimeOptions = RuntimeOptions.defaultOptions();
ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(classLoader, runtimeOptions);
ObjectFactorySupplier objectFactory = new SingletonObjectFactorySupplier(objectFactoryServiceLoader);
BackendServiceLoader backendSupplier = new BackendServiceLoader(classLoader, objectFactory);
eventBus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, eventBus, backendSupplier, objectFactory);
}
use of io.cucumber.core.options.RuntimeOptions in project cucumber-jvm by cucumber.
the class SingletonRunnerSupplierTest method before.
@BeforeEach
void before() {
Supplier<ClassLoader> classLoader = SingletonRunnerSupplier.class::getClassLoader;
RuntimeOptions runtimeOptions = RuntimeOptions.defaultOptions();
ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(classLoader, runtimeOptions);
ObjectFactorySupplier objectFactory = new SingletonObjectFactorySupplier(objectFactoryServiceLoader);
BackendServiceLoader backendSupplier = new BackendServiceLoader(getClass()::getClassLoader, objectFactory);
EventBus eventBus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
runnerSupplier = new SingletonRunnerSupplier(runtimeOptions, eventBus, backendSupplier, objectFactory);
}
use of io.cucumber.core.options.RuntimeOptions in project cucumber-jvm by cucumber.
the class PluginsTest method shouldRegisterCanonicalOrderEventPublisherWithRootEventPublisher.
@Test
void shouldRegisterCanonicalOrderEventPublisherWithRootEventPublisher() {
RuntimeOptions runtimeOptions = RuntimeOptions.defaultOptions();
Plugins plugins = new Plugins(pluginFactory, runtimeOptions);
EventListener plugin = mock(EventListener.class);
plugins.addPlugin(plugin);
plugins.setSerialEventBusOnEventListenerPlugins(rootEventPublisher);
verify(rootEventPublisher, times(1)).registerHandlerFor(eq(Event.class), ArgumentMatchers.any());
}
use of io.cucumber.core.options.RuntimeOptions 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.options.RuntimeOptions in project cucumber-jvm by cucumber.
the class Main method run.
/**
* Launches the Cucumber-JVM command line.
*
* @param argv runtime options. See details in the
* {@code cucumber.api.cli.Usage.txt} resource.
* @param classLoader classloader used to load the runtime
* @return 0 if execution was successful, 1 if it was not (test
* failures)
*/
public static byte run(String[] argv, ClassLoader classLoader) {
RuntimeOptions propertiesFileOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromPropertiesFile()).build();
RuntimeOptions environmentOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromEnvironment()).build(propertiesFileOptions);
RuntimeOptions systemOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromSystemProperties()).build(environmentOptions);
CommandlineOptionsParser commandlineOptionsParser = new CommandlineOptionsParser(System.out);
RuntimeOptions runtimeOptions = commandlineOptionsParser.parse(argv).addDefaultGlueIfAbsent().addDefaultFeaturePathIfAbsent().addDefaultSummaryPrinterIfNotDisabled().enablePublishPlugin().build(systemOptions);
Optional<Byte> exitStatus = commandlineOptionsParser.exitStatus();
if (exitStatus.isPresent()) {
return exitStatus.get();
}
final Runtime runtime = Runtime.builder().withRuntimeOptions(runtimeOptions).withClassLoader(() -> classLoader).build();
runtime.run();
return runtime.exitStatus();
}
Aggregations