use of io.cucumber.plugin.event.TestCase in project cucumber-jvm by cucumber.
the class PrettyFormatter method preCalculateLocationIndent.
private void preCalculateLocationIndent(TestCaseStarted event) {
TestCase testCase = event.getTestCase();
Integer longestStep = testCase.getTestSteps().stream().filter(PickleStepTestStep.class::isInstance).map(PickleStepTestStep.class::cast).map(PickleStepTestStep::getStep).map(step -> formatPlainStep(step.getKeyword(), step.getText()).length()).max(Comparator.naturalOrder()).orElse(0);
int scenarioLength = formatScenarioDefinition(testCase).length();
commentStartIndex.put(testCase.getId(), max(longestStep, scenarioLength) + 1);
}
use of io.cucumber.plugin.event.TestCase in project syndesis-qe by syndesisio.
the class PrettyFormatter method printScenarioDefinition.
private void printScenarioDefinition(TestCaseStarted event) {
TestCase testCase = event.getTestCase();
String definitionText = formatScenarioDefinition(testCase);
String path = relativize(testCase.getUri()).getSchemeSpecificPart();
String locationIndent = calculateLocationIndent(event.getTestCase(), SCENARIO_INDENT + definitionText);
out.println(SCENARIO_INDENT + definitionText + locationIndent + formatLocation(path + ":" + testCase.getLocation().getLine()));
}
use of io.cucumber.plugin.event.TestCase in project syndesis-qe by syndesisio.
the class PrettyFormatter method preCalculateLocationIndent.
private void preCalculateLocationIndent(TestCaseStarted event) {
TestCase testCase = event.getTestCase();
Integer longestStep = testCase.getTestSteps().stream().filter(PickleStepTestStep.class::isInstance).map(PickleStepTestStep.class::cast).map(PickleStepTestStep::getStep).map(step -> formatPlainStep(step.getKeyword(), step.getText()).length()).max(Comparator.naturalOrder()).orElse(0);
int scenarioLength = formatScenarioDefinition(testCase).length();
commentStartIndex.put(testCase.getId(), max(longestStep, scenarioLength) + 1);
}
use of io.cucumber.plugin.event.TestCase in project cucumber-jvm by cucumber.
the class EventBusTest method handlers_receive_the_events_they_registered_for.
@Test
void handlers_receive_the_events_they_registered_for() {
EventHandler<TestStepFinished> handler = mock(EventHandler.class);
PickleStepTestStep testStep = mock(PickleStepTestStep.class);
Result result = new Result(Status.PASSED, ZERO, null);
TestCase testCase = mock(TestCase.class);
TestStepFinished event = new TestStepFinished(EPOCH, testCase, testStep, result);
EventBus bus = new TimeServiceEventBus(Clock.fixed(Instant.EPOCH, ZoneId.of("UTC")), UUID::randomUUID);
bus.registerHandlerFor(TestStepFinished.class, handler);
bus.send(event);
verify(handler).receive(event);
}
use of io.cucumber.plugin.event.TestCase 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);
}
Aggregations