Skip to content

Conversation

@mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Sep 17, 2025

🤔 What's changed?

Adds

  • findAllTestCaseStartedOrderBy
  • findAllTestCaseFinishedOrderBy

⚡️ What's your motivation?

To provide consistent results while executing in parallel, the Cucumber JSON, Teamcity, Pretty, and Rerun formatters all prints results in canonical order. This results in quite some duplication. By providing a function to order the elements by and an ordering, we can remove this duplication while also remaining flexible as to what is ordered. I.e:

    public <T> List<TestCaseStarted> findAllTestCaseStartedOrderBy(BiFunction<Query, TestCaseStarted, Optional<T>> findOrderBy, Comparator<T> order) {
        return findAllTestCaseStarted().stream()
                .map(testCaseStarted -> findOrderBy.apply(this, testCaseStarted)
                        .map(orderBy -> new OrderableMessage<>(testCaseStarted, orderBy))
                        .orElseGet(() -> new OrderableMessage<>(testCaseStarted)))
                .sorted(Comparator.comparing(OrderableMessage::getOrderBy, order))
                .map(OrderableMessage::getMessage)
                .collect(toList());
    }

Then this can be used as:

query.findAllTestCaseStartedOrderBy(
                        Query::findPickleBy,
                        Comparator.nullsFirst(new PickleComparator())
                )

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

…ethods

# Conflicts:
#	java/src/test/java/io/cucumber/query/QueryAcceptanceTest.java
@mpkorstanje mpkorstanje force-pushed the add-canonical-order-methods branch from b902802 to bfa6e25 Compare December 23, 2025 01:53
@mpkorstanje mpkorstanje force-pushed the add-canonical-order-methods branch from bfa6e25 to d685942 Compare December 23, 2025 02:01
@mpkorstanje mpkorstanje force-pushed the add-canonical-order-methods branch from 0872873 to 391b07a Compare December 23, 2025 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant