Search in sources :

Example 1 with Event

use of io.cucumber.plugin.event.Event 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);
}
Also used : TestStepStarted(io.cucumber.plugin.event.TestStepStarted) ExceptionUtils.printStackTrace(io.cucumber.core.exception.ExceptionUtils.printStackTrace) ZonedDateTime(java.time.ZonedDateTime) TestStep(io.cucumber.plugin.event.TestStep) TestSourceParsed(io.cucumber.plugin.event.TestSourceParsed) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) HashMap(java.util.HashMap) Status(io.cucumber.plugin.event.Status) TestCase(io.cucumber.plugin.event.TestCase) Supplier(java.util.function.Supplier) EventListener(io.cucumber.plugin.EventListener) ArrayList(java.util.ArrayList) PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) TestCaseStarted(io.cucumber.plugin.event.TestCaseStarted) Matcher(java.util.regex.Matcher) EmbedEvent(io.cucumber.plugin.event.EmbedEvent) WriteEvent(io.cucumber.plugin.event.WriteEvent) SnippetsSuggestedEvent(io.cucumber.plugin.event.SnippetsSuggestedEvent) TestCaseFinished(io.cucumber.plugin.event.TestCaseFinished) Locale(java.util.Locale) Map(java.util.Map) HookTestStep(io.cucumber.plugin.event.HookTestStep) URI(java.net.URI) ZoneOffset(java.time.ZoneOffset) Event(io.cucumber.plugin.event.Event) EventPublisher(io.cucumber.plugin.event.EventPublisher) PrintStream(java.io.PrintStream) Result(io.cucumber.plugin.event.Result) Predicate(java.util.function.Predicate) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) TestRunStarted(io.cucumber.plugin.event.TestRunStarted) Node(io.cucumber.plugin.event.Node) Location(io.cucumber.plugin.event.Location) Collectors(java.util.stream.Collectors) Collectors.joining(java.util.stream.Collectors.joining) HookType(io.cucumber.plugin.event.HookType) List(java.util.List) Suggestion(io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion) TestRunFinished(io.cucumber.plugin.event.TestRunFinished) DateTimeFormatter(java.time.format.DateTimeFormatter) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) Optional(java.util.Optional) TestCase(io.cucumber.plugin.event.TestCase) Node(io.cucumber.plugin.event.Node) URI(java.net.URI) Location(io.cucumber.plugin.event.Location)

Example 2 with Event

use of io.cucumber.plugin.event.Event in project cucumber-jvm by cucumber.

the class CanonicalEventOrderTest method verifyTestCaseStartedSortedCorrectly.

@Test
void verifyTestCaseStartedSortedCorrectly() {
    final List<Event> greaterThan = Arrays.asList(runStarted, testRead, suggested);
    for (final Event e : greaterThan) {
        assertAll(() -> assertThat(comparator.compare(feature1Case1Started, e), greaterThan(EQUAL_TO)), () -> assertThat(comparator.compare(feature1Case2Started, e), greaterThan(EQUAL_TO)), () -> assertThat(comparator.compare(feature1Case3Started, e), greaterThan(EQUAL_TO)), () -> assertThat(comparator.compare(feature2Case1Started, e), greaterThan(EQUAL_TO)));
    }
    final List<Event> lessThan = Collections.singletonList(runFinished);
    for (final Event e : lessThan) {
        assertAll(() -> assertThat(comparator.compare(feature1Case1Started, e), lessThan(EQUAL_TO)), () -> assertThat(comparator.compare(feature1Case2Started, e), lessThan(EQUAL_TO)), () -> assertThat(comparator.compare(feature1Case3Started, e), lessThan(EQUAL_TO)), () -> assertThat(comparator.compare(feature2Case1Started, e), lessThan(EQUAL_TO)), () -> assertThat(comparator.compare(e, feature1Case1Started), greaterThan(EQUAL_TO)), () -> assertThat(comparator.compare(e, feature1Case2Started), greaterThan(EQUAL_TO)), () -> assertThat(comparator.compare(e, feature1Case3Started), greaterThan(EQUAL_TO)), () -> assertThat(comparator.compare(e, feature2Case1Started), greaterThan(EQUAL_TO)));
    }
    assertAll(() -> assertThat(comparator.compare(feature1Case1Started, feature1Case1Started), equalTo(EQUAL_TO)), () -> assertThat(comparator.compare(feature1Case1Started, feature1Case1Started2), lessThan(EQUAL_TO)), () -> assertThat(comparator.compare(feature1Case1Started, feature1Case2Started), lessThan(EQUAL_TO)), () -> assertThat(comparator.compare(feature1Case1Started, feature1Case2Started), lessThan(EQUAL_TO)), () -> assertThat(comparator.compare(feature1Case2Started, feature1Case3Started), lessThan(EQUAL_TO)), () -> assertThat(comparator.compare(feature1Case3Started, feature2Case1Started), lessThan(EQUAL_TO)));
}
Also used : SnippetsSuggestedEvent(io.cucumber.plugin.event.SnippetsSuggestedEvent) Event(io.cucumber.plugin.event.Event) Test(org.junit.jupiter.api.Test)

Aggregations

Event (io.cucumber.plugin.event.Event)2 SnippetsSuggestedEvent (io.cucumber.plugin.event.SnippetsSuggestedEvent)2 ExceptionUtils.printStackTrace (io.cucumber.core.exception.ExceptionUtils.printStackTrace)1 EventListener (io.cucumber.plugin.EventListener)1 EmbedEvent (io.cucumber.plugin.event.EmbedEvent)1 EventPublisher (io.cucumber.plugin.event.EventPublisher)1 HookTestStep (io.cucumber.plugin.event.HookTestStep)1 HookType (io.cucumber.plugin.event.HookType)1 Location (io.cucumber.plugin.event.Location)1 Node (io.cucumber.plugin.event.Node)1 PickleStepTestStep (io.cucumber.plugin.event.PickleStepTestStep)1 Result (io.cucumber.plugin.event.Result)1 Suggestion (io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion)1 Status (io.cucumber.plugin.event.Status)1 TestCase (io.cucumber.plugin.event.TestCase)1 TestCaseFinished (io.cucumber.plugin.event.TestCaseFinished)1 TestCaseStarted (io.cucumber.plugin.event.TestCaseStarted)1 TestRunFinished (io.cucumber.plugin.event.TestRunFinished)1 TestRunStarted (io.cucumber.plugin.event.TestRunStarted)1 TestSourceParsed (io.cucumber.plugin.event.TestSourceParsed)1