use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class CoreStepDefinitionTest method should_apply_identity_transform_to_doc_string_when_target_type_is_object.
@Test
void should_apply_identity_transform_to_doc_string_when_target_type_is_object() {
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given I have some step\n" + " \"\"\"\n" + " content\n" + " \"\"\"\n");
StepDefinition stepDefinition = new StubStepDefinition("I have some step", Object.class);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
CoreStepDefinition coreStepDefinition = new CoreStepDefinition(id, stepDefinition, expression);
Step step = feature.getPickles().get(0).getSteps().get(0);
List<Argument> arguments = coreStepDefinition.matchedArguments(step);
assertThat(arguments.get(0).getValue(), is(equalTo(DocString.create("content"))));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class CoreStepDefinitionTest method passes_plain_data_table.
@Test
void passes_plain_data_table() throws Throwable {
Method m = Steps.class.getMethod("plainDataTable", DataTable.class);
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given some text\n" + " | Birth Date | \n" + " | 1957-05-10 | \n");
DataTable stepDefs = runStepDef(m, false, feature);
assertAll(() -> assertThat(stepDefs.cell(0, 0), is(equalTo("Birth Date"))), () -> assertThat(stepDefs.cell(1, 0), is(equalTo("1957-05-10"))));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class CoreStepDefinitionTest method transforms_to_list_of_single_values.
@Test
void transforms_to_list_of_single_values() throws Throwable {
Method m = Steps.class.getMethod("listOfListOfDoubles", List.class);
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given some text\n" + " | 100.5 | 99.5 | \n" + " | 0.5 | -0.5 | \n" + " | 1000 | 999 | \n");
List<List<Double>> stepDefs = runStepDef(m, false, feature);
assertThat(stepDefs.toString(), is(equalTo("[[100.5, 99.5], [0.5, -0.5], [1000.0, 999.0]]")));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class RunnerTest method createPickleMatchingStepDefinitions.
private Pickle createPickleMatchingStepDefinitions(StubStepDefinition stepDefinition) {
String pattern = stepDefinition.getPattern();
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given " + pattern + "\n");
return feature.getPickles().get(0);
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class TestCaseStateTest method attach_string_emits_event_on_bus.
@Test
void attach_string_emits_event_on_bus() {
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given I have 4 cukes in my belly\n");
TestCaseState state = createTestCaseState(feature);
List<EmbedEvent> embedEvents = new ArrayList<>();
List<Envelope> envelopes = new ArrayList<>();
bus.registerHandlerFor(EmbedEvent.class, embedEvents::add);
bus.registerHandlerFor(Envelope.class, envelopes::add);
UUID activeTestStep = UUID.randomUUID();
state.setCurrentTestStepId(activeTestStep);
state.attach("Hello World", "text/plain", "hello.txt");
EmbedEvent embedEvent = embedEvents.get(0);
assertThat(embedEvent.getData(), is("Hello World".getBytes(UTF_8)));
assertThat(embedEvent.getMediaType(), is("text/plain"));
assertThat(embedEvent.getName(), is("hello.txt"));
Envelope envelope = envelopes.get(0);
assertThat(envelope.getAttachment().getBody(), is("Hello World"));
assertThat(envelope.getAttachment().getContentEncoding(), is(ContentEncoding.IDENTITY));
assertThat(envelope.getAttachment().getMediaType(), is("text/plain"));
assertThat(envelope.getAttachment().getFileName(), is("hello.txt"));
assertThat(envelope.getAttachment().getTestStepId(), is(activeTestStep.toString()));
assertThat(envelope.getAttachment().getTestCaseStartedId(), is(state.getTestExecutionId().toString()));
}
Aggregations