Skip to content

Commit 326a40e

Browse files
committed
[Core] Deprecate multiple tag arguments in @CucumberOptions
Passing multiple tags through `@CucumberOptions` has confusing semantics. Using a single tag expressions clears up any confusion and harmonizes ``@CucumberOptions` with `cucumber.filter.tags`. For example: ```java @CucumberOptions(tags="(@cucumber or @Pickle) and not @salad") ``` ```properties cucumber.filter.tags="(@cucumber or @Pickle) and not @salad" ``` Partial fix for: #1948
1 parent 0608f18 commit 326a40e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

core/src/main/java/io/cucumber/core/options/CucumberOptionsAnnotationParser.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import io.cucumber.core.exception.CucumberException;
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;
79
import io.cucumber.core.snippets.SnippetType;
810

911
import java.nio.file.Path;
@@ -15,6 +17,9 @@
1517
import static java.util.Objects.requireNonNull;
1618

1719
public final class CucumberOptionsAnnotationParser {
20+
21+
private final Logger log = LoggerFactory.getLogger(CucumberOptionsAnnotationParser.class);
22+
1823
private boolean featuresSpecified = false;
1924
private boolean overridingGlueSpecified = false;
2025
private OptionsProvider optionsProvider;
@@ -87,8 +92,15 @@ private void addMonochrome(CucumberOptions options, RuntimeOptionsBuilder args)
8792
}
8893

8994
private void addTags(CucumberOptions options, RuntimeOptionsBuilder args) {
90-
for (String tags : options.tags()) {
91-
args.addTagFilter(tags);
95+
String[] tags = options.tags();
96+
if (tags.length > 1) {
97+
log.warn(() -> "" +
98+
"Passing multiple tags through @CucumberOptions is deprecated.\n" +
99+
"Please use a single tag expressions e.g: @CucumberOptions(tags=\"(@cucumber or @pickle) and not @salad\")"
100+
);
101+
}
102+
for (String tagExpression : tags) {
103+
args.addTagFilter(tagExpression);
92104
}
93105
}
94106

0 commit comments

Comments
 (0)