use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class DryRunTest method dry_run_passes_skipped_step.
@Test
void dry_run_passes_skipped_step() {
Feature skipped = TestFeatureParser.parse("1/skipped.feature", "Feature: skipped\n" + " Scenario: skipped\n" + " * skipped step\n");
StepStatusSpy out = new StepStatusSpy();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(skipped)).withAdditionalPlugins(out).withBackendSupplier(backend).withRuntimeOptions(new RuntimeOptionsBuilder().setDryRun().build()).build().run();
assertThat(out.toString(), is("" + "skipped\n" + " PASSED\n"));
}
use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class DryRunTest method dry_run_passes_failed_step.
@Test
void dry_run_passes_failed_step() {
Feature failed = TestFeatureParser.parse("5/failed.feature", "Feature: failed\n" + " Scenario: failed\n" + " * failed step\n");
StepStatusSpy out = new StepStatusSpy();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(failed)).withAdditionalPlugins(out).withBackendSupplier(backend).withRuntimeOptions(new RuntimeOptionsBuilder().setDryRun().build()).build().run();
assertThat(out.toString(), is("" + "failed\n" + " PASSED\n"));
}
use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class CompatibilityTest method produces_expected_output_for.
@ParameterizedTest
@MethodSource("io.cucumber.compatibility.TestCase#testCases")
void produces_expected_output_for(TestCase testCase) throws IOException {
Path parentDir = Files.createDirectories(Paths.get("target", "messages", testCase.getId()));
Path outputNdjson = parentDir.resolve("out.ndjson");
Path outputHtml = parentDir.resolve("out.html");
Path outputJson = parentDir.resolve("out.json");
try {
Runtime.builder().withRuntimeOptions(new RuntimeOptionsBuilder().addGlue(testCase.getGlue()).addFeature(testCase.getFeature()).build()).withAdditionalPlugins(new MessageFormatter(newOutputStream(outputNdjson)), new HtmlFormatter(newOutputStream(outputHtml)), new JsonFormatter(newOutputStream(outputJson))).build().run();
} catch (Exception ignored) {
}
List<JsonNode> expected = readAllMessages(testCase.getExpectedFile());
List<JsonNode> actual = readAllMessages(outputNdjson);
Map<String, List<JsonNode>> expectedEnvelopes = openEnvelopes(expected);
Map<String, List<JsonNode>> actualEnvelopes = openEnvelopes(actual);
// exception: Java step definitions are not in a predictable order
// because Class#getMethods() does not return a predictable order.
sortStepDefinitions(expectedEnvelopes);
sortStepDefinitions(actualEnvelopes);
// unknown-parameter-types
if ("unknown-parameter-type".equals(testCase.getId())) {
expectedEnvelopes.remove("testCase");
expectedEnvelopes.remove("testCaseStarted");
expectedEnvelopes.remove("testStepStarted");
expectedEnvelopes.remove("testStepFinished");
expectedEnvelopes.remove("testCaseFinished");
}
expectedEnvelopes.forEach((messageType, expectedMessages) -> assertThat(actualEnvelopes, hasEntry(is(messageType), containsInRelativeOrder(aComparableMessage(expectedMessages)))));
}
use of io.cucumber.core.options.RuntimeOptionsBuilder 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.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_skip_missing_location_strings.
@Test
void should_skip_missing_location_strings() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n");
ByteArrayOutputStream out = new ByteArrayOutputStream();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new PrettyFormatter(out)).withRuntimeOptions(new RuntimeOptionsBuilder().setMonochrome().build()).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", "path/step_definitions.java:3"), new StubStepDefinition("second step", (String) null), new StubStepDefinition("third step", "path/step_definitions.java:11"))).build().run();
assertThat(out, isBytesEqualTo("" + "\n" + "Scenario: scenario name # path/test.feature:2\n" + " Given first step # path/step_definitions.java:3\n" + " When second step\n" + " Then third step # path/step_definitions.java:11\n"));
}
Aggregations