use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class RuntimeTest method should_interrupt_waiting_plugins.
@Test
void should_interrupt_waiting_plugins() throws InterruptedException {
final Feature feature1 = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name 1\n" + " Scenario: scenario_1 name\n" + " Given first step\n" + " Scenario: scenario_2 name\n" + " Given first step\n");
final Feature feature2 = TestFeatureParser.parse("path/test2.feature", "" + "Feature: feature name 2\n" + " Scenario: scenario_2 name\n" + " Given first step\n");
final CountDownLatch threadBlocked = new CountDownLatch(1);
final CountDownLatch interruptHit = new CountDownLatch(1);
final ConcurrentEventListener brokenEventListener = publisher -> publisher.registerHandlerFor(TestStepFinished.class, (TestStepFinished event) -> {
try {
threadBlocked.countDown();
HOURS.sleep(1);
} catch (InterruptedException ignored) {
interruptHit.countDown();
}
});
Thread thread = new Thread(() -> Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature1, feature2)).withAdditionalPlugins(brokenEventListener).withRuntimeOptions(new RuntimeOptionsBuilder().setThreads(2).build()).build().run());
thread.start();
threadBlocked.await(1, SECONDS);
thread.interrupt();
interruptHit.await(1, SECONDS);
assertThat(interruptHit.getCount(), is(equalTo(0L)));
}
use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class RuntimeTest method should_call_formatter_with_correct_sequence_of_events_when_running_in_parallel.
@Test
void should_call_formatter_with_correct_sequence_of_events_when_running_in_parallel() {
Feature feature1 = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name 1\n" + " Scenario: scenario_1 name\n" + " Given first step\n" + " Scenario: scenario_2 name\n" + " Given first step\n");
Feature feature2 = TestFeatureParser.parse("path/test2.feature", "" + "Feature: feature name 2\n" + " Scenario: scenario_2 name\n" + " Given first step\n");
Feature feature3 = TestFeatureParser.parse("path/test3.feature", "" + "Feature: feature name 3\n" + " Scenario: scenario_3 name\n" + " Given first step\n");
FormatterSpy formatterSpy = new FormatterSpy();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature1, feature2, feature3)).withAdditionalPlugins(formatterSpy).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step"))).withRuntimeOptions(new RuntimeOptionsBuilder().setThreads(3).build()).build().run();
String formatterOutput = formatterSpy.toString();
assertThat(formatterOutput, is(equalTo("" + "TestRun started\n" + " TestCase started\n" + " TestStep started\n" + " TestStep finished\n" + " TestCase finished\n" + " TestCase started\n" + " TestStep started\n" + " TestStep finished\n" + " TestCase finished\n" + " TestCase started\n" + " TestStep started\n" + " TestStep finished\n" + " TestCase finished\n" + " TestCase started\n" + " TestStep started\n" + " TestStep finished\n" + " TestCase finished\n" + "TestRun finished\n")));
}
use of io.cucumber.core.options.RuntimeOptionsBuilder 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.RuntimeOptionsBuilder 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.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class DryRunTest method dry_run_skips_all_steps_after_ambiguous_step.
@Test
void dry_run_skips_all_steps_after_ambiguous_step() {
StepStatusSpy out = new StepStatusSpy();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(ambiguous)).withAdditionalPlugins(out).withBackendSupplier(backend).withRuntimeOptions(new RuntimeOptionsBuilder().setDryRun().build()).build().run();
assertThat(out.toString(), is("" + "ambiguous\n" + " AMBIGUOUS\n" + " SKIPPED\n" + " SKIPPED\n" + " SKIPPED\n" + " SKIPPED\n" + " SKIPPED\n" + " SKIPPED\n"));
}
Aggregations