use of io.cucumber.plugin.event.Node in project cucumber-jvm by cucumber.
the class TimelineFormatter method findRootNodeName.
private String findRootNodeName(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.Node in project cucumber-jvm by cucumber.
the class FeatureParserTest method unnamed_elements_return_empty_strings_as_name.
@Test
void unnamed_elements_return_empty_strings_as_name() throws IOException {
URI uri = URI.create("classpath:com/example.feature");
String source = new String(readAllBytes(Paths.get("src/test/resources/io/cucumber/core/gherkin/messages/unnamed.feature")));
Feature feature = parser.parse(uri, source, UUID::randomUUID).get();
assertEquals(Optional.empty(), feature.getName());
Node.Rule rule = (Node.Rule) feature.elements().iterator().next();
assertEquals(Optional.empty(), rule.getName());
assertEquals(Optional.of("Rule"), rule.getKeyword());
Iterator<Node> ruleElements = rule.elements().iterator();
Node.Scenario scenario = (Node.Scenario) ruleElements.next();
assertEquals(Optional.empty(), scenario.getName());
assertEquals(Optional.of("Scenario"), scenario.getKeyword());
Node.ScenarioOutline scenarioOutline = (Node.ScenarioOutline) ruleElements.next();
assertEquals(Optional.empty(), scenarioOutline.getName());
assertEquals(Optional.of("Scenario Outline"), scenarioOutline.getKeyword());
Node.Examples examples = scenarioOutline.elements().iterator().next();
assertEquals(Optional.empty(), examples.getName());
assertEquals(Optional.of("Examples"), examples.getKeyword());
Node.Example example = examples.elements().iterator().next();
// Example is the exception.
assertEquals(Optional.of("Example #1"), example.getName());
assertEquals(Optional.empty(), example.getKeyword());
}
use of io.cucumber.plugin.event.Node 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.Node 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");
}
Aggregations