Skip to content

Commit a63162a

Browse files
committed
Polishing
1 parent 9c317a0 commit a63162a

File tree

3 files changed

+36
-33
lines changed

3 files changed

+36
-33
lines changed

CHANGELOG.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1010
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1111

1212
## [Unreleased]
13+
### Added
14+
- [JUnit Platform Engine] Added option to include a parameterized scenario name only if the scenario is parameterized ([#2835](https://github.com/cucumber/cucumber-jvm/pull/2835) M.P. Korstanje)
15+
- [JUnit Platform Engine] Added option order features and scenarios ([#2835](https://github.com/cucumber/cucumber-jvm/pull/2835) M.P. Korstanje)
16+
- [JUnit Platform Engine] Log warnings when a classpath resource selector is (e.g. `@SelectClasspathResource`) is used to select a directory. ([#2835](https://github.com/cucumber/cucumber-jvm/pull/2835) M.P. Korstanje)
17+
18+
### Changed
19+
- [JUnit Platform Engine] Use JUnit's `EngineDiscoveryRequestResolver` to resolve classpath based resources. ([#2835](https://github.com/cucumber/cucumber-jvm/pull/2835) M.P. Korstanje)
1320

1421
## [7.22.0] - 2025-04-05
1522
### Changed
@@ -18,11 +25,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1825
- [Java, Java8] Significantly reduced number of emitted step- and hook-definition messages ([#2971](https://github.com/cucumber/cucumber-jvm/pull/2971) M.P. Korstanje & Julien Kronegg)
1926
- [Core] Removed workarounds to limit size of html report ([#2971](https://github.com/cucumber/cucumber-jvm/pull/2971) M.P. Korstanje & Julien Kronegg)
2027
- [JUnit Platform Engine] Use JUnit Platform 1.12.0 (JUnit Jupiter 5.12.0)
21-
- [JUnit Platform Engine] Use JUnit's `EngineDiscoveryRequestResolver` to resolve classpath based resources. ([#2835](https://github.com/cucumber/cucumber-jvm/pull/2835) M.P. Korstanje)
22-
23-
### Added
24-
- [JUnit Platform Engine] Added option to include a parameterized scenario name only if the scenario is parameterized ([#2835](https://github.com/cucumber/cucumber-jvm/pull/2835) M.P. Korstanje)
25-
- [JUnit Platform Engine] Log warnings when a classpath resource selector is (e.g. `@SelectClasspathResource`) is used to select a directory. ([#2835](https://github.com/cucumber/cucumber-jvm/pull/2835) M.P. Korstanje)
2628

2729
### Deprecated
2830
- [Core] Deprecated `ScenarioScoped` glue ([#2971](https://github.com/cucumber/cucumber-jvm/pull/2971) M.P. Korstanje & Julien Kronegg)

cucumber-junit-platform-engine/src/main/java/io/cucumber/junit/platform/engine/CucumberConfiguration.java

+1-28
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import io.cucumber.core.eventbus.UuidGenerator;
55
import io.cucumber.core.feature.FeatureWithLines;
66
import io.cucumber.core.feature.GluePath;
7-
import io.cucumber.core.logging.Logger;
8-
import io.cucumber.core.logging.LoggerFactory;
97
import io.cucumber.core.options.ObjectFactoryParser;
108
import io.cucumber.core.options.PluginOption;
119
import io.cucumber.core.options.SnippetTypeParser;
@@ -27,10 +25,8 @@
2725
import java.util.List;
2826
import java.util.Locale;
2927
import java.util.Optional;
30-
import java.util.Random;
3128
import java.util.Set;
3229
import java.util.function.UnaryOperator;
33-
import java.util.regex.Matcher;
3430
import java.util.regex.Pattern;
3531
import java.util.stream.Collectors;
3632

@@ -61,7 +57,6 @@ class CucumberConfiguration implements
6157
io.cucumber.core.backend.Options,
6258
io.cucumber.core.eventbus.Options {
6359

64-
private static final Logger log = LoggerFactory.getLogger(CucumberConfiguration.class);
6560
private final ConfigurationParameters configurationParameters;
6661

6762
CucumberConfiguration(ConfigurationParameters configurationParameters) {
@@ -216,29 +211,7 @@ ExclusiveResourceConfiguration getExclusiveResourceConfiguration(String tag) {
216211
}
217212

218213
UnaryOperator<List<AbstractCucumberTestDescriptor>> getOrderer() {
219-
return configurationParameters.get(EXECUTION_ORDER_PROPERTY_NAME, order -> {
220-
if (order.equals("lexical")) {
221-
return StandardDescriptorOrders.lexicalUriOrder();
222-
}
223-
if (order.equals("reverse")) {
224-
return StandardDescriptorOrders.reverseLexicalUriOrder();
225-
}
226-
Pattern randomAndSeedPattern = Pattern.compile("random(?::(\\d+))?");
227-
Matcher matcher = randomAndSeedPattern.matcher(order);
228-
if (!matcher.matches()) {
229-
throw new IllegalArgumentException("Invalid order. Must be either reverse, random or random:<long>");
230-
}
231-
final long seed;
232-
String seedString = matcher.group(1);
233-
if (seedString != null) {
234-
seed = Long.parseLong(seedString);
235-
return StandardDescriptorOrders.random(seed);
236-
} else {
237-
seed = Math.abs(new Random().nextLong());
238-
log.info(() -> "Using random test descriptor order. Seed: " + seed);
239-
return StandardDescriptorOrders.random(seed);
240-
}
241-
})
214+
return configurationParameters.get(EXECUTION_ORDER_PROPERTY_NAME, StandardDescriptorOrders::parseOrderer)
242215
.orElseGet(StandardDescriptorOrders::lexicalUriOrder);
243216
}
244217
}

cucumber-junit-platform-engine/src/main/java/io/cucumber/junit/platform/engine/StandardDescriptorOrders.java

+28
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package io.cucumber.junit.platform.engine;
22

3+
import io.cucumber.core.logging.Logger;
4+
import io.cucumber.core.logging.LoggerFactory;
5+
36
import java.util.Collections;
47
import java.util.Comparator;
58
import java.util.List;
69
import java.util.Random;
710
import java.util.function.UnaryOperator;
11+
import java.util.regex.Matcher;
12+
import java.util.regex.Pattern;
813

914
final class StandardDescriptorOrders {
15+
private static final Logger log = LoggerFactory.getLogger(StandardDescriptorOrders.class);
1016

1117
private static final Comparator<AbstractCucumberTestDescriptor> lexical = Comparator
1218
.comparing(AbstractCucumberTestDescriptor::getUri)
@@ -39,4 +45,26 @@ static UnaryOperator<List<AbstractCucumberTestDescriptor>> random(final long see
3945
};
4046
}
4147

48+
static UnaryOperator<List<AbstractCucumberTestDescriptor>> parseOrderer(String order) {
49+
if (order.equals("lexical")) {
50+
return StandardDescriptorOrders.lexicalUriOrder();
51+
}
52+
if (order.equals("reverse")) {
53+
return StandardDescriptorOrders.reverseLexicalUriOrder();
54+
}
55+
Pattern randomAndSeedPattern = Pattern.compile("random(?::(\\d+))?");
56+
Matcher matcher = randomAndSeedPattern.matcher(order);
57+
if (!matcher.matches()) {
58+
throw new IllegalArgumentException("Invalid order. Must be either reverse, random or random:<long>");
59+
}
60+
final long seed;
61+
String seedString = matcher.group(1);
62+
if (seedString != null) {
63+
seed = Long.parseLong(seedString);
64+
} else {
65+
seed = Math.abs(new Random().nextLong());
66+
log.info(() -> "Using random test descriptor order. Seed: " + seed);
67+
}
68+
return StandardDescriptorOrders.random(seed);
69+
}
4270
}

0 commit comments

Comments
 (0)