use of io.cucumber.plugin.event.Location in project cucumber-jvm by cucumber.
the class GherkinMessagesPickle method createCucumberSteps.
private static List<Step> createCucumberSteps(io.cucumber.messages.types.Pickle pickle, GherkinDialect dialect, CucumberQuery cucumberQuery) {
List<Step> list = new ArrayList<>();
String previousGivenWhenThen = dialect.getGivenKeywords().stream().filter(s -> !StepType.isAstrix(s)).findFirst().orElseThrow(() -> new IllegalStateException("No Given keyword for dialect: " + dialect.getName()));
for (io.cucumber.messages.types.PickleStep pickleStep : pickle.getSteps()) {
String gherkinStepId = pickleStep.getAstNodeIds().get(0);
io.cucumber.messages.types.Step gherkinStep = cucumberQuery.getGherkinStep(gherkinStepId);
Location location = GherkinMessagesLocation.from(gherkinStep.getLocation());
String keyword = gherkinStep.getKeyword();
Step step = new GherkinMessagesStep(pickleStep, dialect, previousGivenWhenThen, location, keyword);
if (step.getType().isGivenWhenThen()) {
previousGivenWhenThen = step.getKeyword();
}
list.add(step);
}
return list;
}
use of io.cucumber.plugin.event.Location in project cucumber-jvm by cucumber.
the class TeamCityPlugin method printTestCaseStarted.
private void printTestCaseStarted(TestCaseStarted event) {
TestCase testCase = event.getTestCase();
URI uri = testCase.getUri();
String timestamp = extractTimeStamp(event);
Location location = testCase.getLocation();
Predicate<Node> withLocation = candidate -> location.equals(candidate.getLocation());
List<Node> path = parsedTestSources.get(uri).stream().map(node -> node.findPathTo(withLocation)).filter(Optional::isPresent).map(Optional::get).findFirst().orElse(emptyList());
poppedNodes(path).forEach(node -> finishNode(timestamp, node));
pushedNodes(path).forEach(node -> startNode(uri, timestamp, node));
this.currentStack = path;
this.currentTestCase = testCase;
print(TEMPLATE_PROGRESS_TEST_STARTED, timestamp);
}
use of io.cucumber.plugin.event.Location in project cucumber-jvm by cucumber.
the class TestNGFormatter method findRootNodeName.
private String findRootNodeName(io.cucumber.plugin.event.TestCase testCase) {
Location location = testCase.getLocation();
Predicate<Node> withLocation = candidate -> candidate.getLocation().equals(location);
return parsedTestSources.get(testCase.getUri()).stream().map(node -> node.findPathTo(withLocation)).filter(Optional::isPresent).map(Optional::get).findFirst().map(nodes -> nodes.get(0)).flatMap(Node::getName).orElse("Unknown");
}
use of io.cucumber.plugin.event.Location in project cucumber-jvm by cucumber.
the class DefaultSummaryPrinterTest method does_not_print_duplicate_snippets.
@Test
void does_not_print_duplicate_snippets() {
bus.send(new SnippetsSuggestedEvent(bus.getInstant(), URI.create("classpath:com/example.feature"), new Location(12, -1), new Location(13, -1), new Suggestion("", singletonList("snippet"))));
bus.send(new SnippetsSuggestedEvent(bus.getInstant(), URI.create("classpath:com/example.feature"), new Location(12, -1), new Location(14, -1), new Suggestion("", singletonList("snippet"))));
bus.send(new TestRunFinished(bus.getInstant(), new Result(Status.PASSED, Duration.ZERO, null)));
assertThat(new String(out.toByteArray(), UTF_8), equalToCompressingWhiteSpace("" + "\n" + "0 Scenarios\n" + "0 Steps\n" + "0m0.000s\n" + "\n" + "\n" + "You can implement missing steps with the snippets below:\n" + "\n" + "snippet\n" + "\n" + "\n"));
}
use of io.cucumber.plugin.event.Location in project cucumber-jvm by cucumber.
the class CanonicalEventOrderTest method createTestCaseEvent.
private static TestCaseStarted createTestCaseEvent(Instant instant, URI uri, int line) {
final TestCase testCase = mock(TestCase.class);
given(testCase.getUri()).willReturn(uri);
given(testCase.getLocation()).willReturn(new Location(line, -1));
return new TestCaseStarted(instant, testCase);
}
Aggregations