Skip to content

Commit 464d1c1

Browse files
committed
[Core] Remove --strict and --no-strict options
Cucumber executes scenarios in strict mode by default. Fixes: #1788
1 parent 8c0a477 commit 464d1c1

20 files changed

+37
-181
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2525
### Deprecated
2626

2727
### Removed
28+
* [Core] Removed `--strict` and `--no-strict` options ([#1788](https://github.com/cucumber/cucumber-jvm/issues/1788) M.P. Korstanje)
29+
- Cucumber executes scenarios in strict mode by default
2830

2931
### Fixed
3032

core/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ cucumber.execution.limit= # number of scenarios to execute (CLI only).
2828
2929
cucumber.execution.order= # lexical, reverse, random or random:[seed] (CLI only). default: lexical
3030
31-
cucumber.execution.strict= # true or false. default: false.
32-
3331
cucumber.execution.wip= # true or false. default: false.
3432
# Fails if there any passing scenarios
3533
# CLI only.

core/src/main/java/io/cucumber/core/cli/CommandlineOptions.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ public final class CommandlineOptions {
4747
public static final String DRY_RUN = "--dry-run";
4848
public static final String DRY_RUN_SHORT = "-d";
4949

50-
public static final String NO_STRICT = "--no-strict";
51-
52-
public static final String STRICT = "--strict";
53-
public static final String STRICT_SHORT = "-s";
54-
5550
public static final String NO_MONOCHROME = "--no-monochrome";
5651

5752
public static final String MONOCHROME = "--monochrome";

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,13 @@
4242
import static io.cucumber.core.cli.CommandlineOptions.NAME_SHORT;
4343
import static io.cucumber.core.cli.CommandlineOptions.NO_DRY_RUN;
4444
import static io.cucumber.core.cli.CommandlineOptions.NO_MONOCHROME;
45-
import static io.cucumber.core.cli.CommandlineOptions.NO_STRICT;
4645
import static io.cucumber.core.cli.CommandlineOptions.NO_SUMMARY;
4746
import static io.cucumber.core.cli.CommandlineOptions.OBJECT_FACTORY;
4847
import static io.cucumber.core.cli.CommandlineOptions.ORDER;
4948
import static io.cucumber.core.cli.CommandlineOptions.PLUGIN;
5049
import static io.cucumber.core.cli.CommandlineOptions.PLUGIN_SHORT;
5150
import static io.cucumber.core.cli.CommandlineOptions.PUBLISH;
5251
import static io.cucumber.core.cli.CommandlineOptions.SNIPPETS;
53-
import static io.cucumber.core.cli.CommandlineOptions.STRICT;
54-
import static io.cucumber.core.cli.CommandlineOptions.STRICT_SHORT;
5552
import static io.cucumber.core.cli.CommandlineOptions.TAGS;
5653
import static io.cucumber.core.cli.CommandlineOptions.TAGS_SHORT;
5754
import static io.cucumber.core.cli.CommandlineOptions.THREADS;
@@ -141,14 +138,8 @@ private RuntimeOptionsBuilder parse(List<String> args) {
141138
parsedOptions.setDryRun(true);
142139
} else if (arg.equals(NO_DRY_RUN)) {
143140
parsedOptions.setDryRun(false);
144-
} else if (arg.equals(NO_STRICT)) {
145-
out.println("--no-strict is no longer effective");
146-
exitCode = 1;
147-
return parsedOptions;
148141
} else if (arg.equals(NO_SUMMARY)) {
149142
parsedOptions.setNoSummary();
150-
} else if (arg.equals(STRICT) || arg.equals(STRICT_SHORT)) {
151-
log.warn(() -> "--strict is enabled by default. This option will be removed in a future release.");
152143
} else if (arg.equals(MONOCHROME) || arg.equals(MONOCHROME_SHORT)) {
153144
parsedOptions.setMonochrome(true);
154145
} else if (arg.equals(NO_MONOCHROME)) {

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ public final class Constants {
4545
*/
4646
public static final String EXECUTION_ORDER_PROPERTY_NAME = "cucumber.execution.order";
4747

48-
/**
49-
* Property name used to disable strict execution: {@value}
50-
* <p>
51-
* When using strict execution Cucumber will treat undefined and pending
52-
* steps as errors.
53-
* <p>
54-
* By default, strict execution is enabled.
55-
*/
56-
public static final String EXECUTION_STRICT_PROPERTY_NAME = "cucumber.execution.strict";
57-
5848
/**
5949
* Property name used to enable wip execution: {@value}
6050
* <p>

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public RuntimeOptionsBuilder parse(Class<?> clazz) {
4040
addTags(classWithOptions, options, args);
4141
addPlugins(options, args);
4242
addPublish(options, args);
43-
addStrict(options, args);
4443
addName(options, args);
4544
addSnippets(options, args);
4645
addGlue(options, args);
@@ -94,13 +93,6 @@ private void addPublish(CucumberOptions options, RuntimeOptionsBuilder args) {
9493
}
9594
}
9695

97-
private void addStrict(CucumberOptions options, RuntimeOptionsBuilder args) {
98-
if (!options.strict()) {
99-
throw new CucumberException(
100-
"@CucumberOptions(strict=false) is no longer supported. Please use strict=true");
101-
}
102-
}
103-
10496
private void addName(CucumberOptions options, RuntimeOptionsBuilder args) {
10597
for (String name : options.name()) {
10698
Pattern pattern = Pattern.compile(name);
@@ -196,8 +188,6 @@ public interface CucumberOptions {
196188

197189
boolean dryRun();
198190

199-
boolean strict();
200-
201191
String[] features();
202192

203193
String[] glue();

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import static io.cucumber.core.options.Constants.EXECUTION_DRY_RUN_PROPERTY_NAME;
2020
import static io.cucumber.core.options.Constants.EXECUTION_LIMIT_PROPERTY_NAME;
2121
import static io.cucumber.core.options.Constants.EXECUTION_ORDER_PROPERTY_NAME;
22-
import static io.cucumber.core.options.Constants.EXECUTION_STRICT_PROPERTY_NAME;
2322
import static io.cucumber.core.options.Constants.FEATURES_PROPERTY_NAME;
2423
import static io.cucumber.core.options.Constants.FILTER_NAME_PROPERTY_NAME;
2524
import static io.cucumber.core.options.Constants.FILTER_TAGS_PROPERTY_NAME;
@@ -60,11 +59,6 @@ public RuntimeOptionsBuilder parse(Map<String, String> properties) {
6059
PickleOrderParser::parse,
6160
builder::setPickleOrder);
6261

63-
parse(properties,
64-
EXECUTION_STRICT_PROPERTY_NAME,
65-
BooleanString::parseBoolean,
66-
CucumberPropertiesParser::errorOnNonStrict);
67-
6862
parseAll(properties,
6963
FEATURES_PROPERTY_NAME,
7064
splitAndThenFlatMap(CucumberPropertiesParser::parseFeatureFile),
@@ -134,13 +128,6 @@ private <T> void parse(
134128
parseAll(properties, propertyName, parser.andThen(Collections::singletonList), setter);
135129
}
136130

137-
private static void errorOnNonStrict(Boolean strict) {
138-
if (!strict) {
139-
throw new CucumberException(EXECUTION_STRICT_PROPERTY_NAME
140-
+ "=false is no longer effective. Please use =true (the default) or remove this property");
141-
}
142-
}
143-
144131
private <T> void parseAll(
145132
Map<String, String> properties, String propertyName, Function<String, Collection<T>> parser,
146133
Consumer<T> setter

core/src/main/resources/io/cucumber/core/options/USAGE.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ cucumber.execution.limit= # number of scenarios to execute (CLI only).
117117

118118
cucumber.execution.order= # lexical, reverse, random or random:[seed] (CLI only). default: lexical
119119

120-
cucumber.execution.strict= # true or false. default: false.
121-
122120
cucumber.execution.wip= # true or false. default: false.
123121
# Fails if there any passing scenarios
124122
# CLI only.

core/src/test/java/io/cucumber/core/options/CommandlineOptionsParserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void set_monochrome_on_color_aware_formatters() {
421421
@Test
422422
void set_strict_on_strict_aware_formatters() {
423423
RuntimeOptions options = parser
424-
.parse("--strict", "--plugin", AwareFormatter.class.getName())
424+
.parse("--plugin", AwareFormatter.class.getName())
425425
.build();
426426
Plugins plugins = new Plugins(new PluginFactory(), options);
427427
plugins.setEventBusOnEventListenerPlugins(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));

core/src/test/java/io/cucumber/core/options/CucumberOptions.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
boolean dryRun() default false;
1515

16-
boolean strict() default true;
17-
1816
String[] features() default {};
1917

2018
String[] glue() default {};

core/src/test/java/io/cucumber/core/options/CucumberOptionsAnnotationParserTest.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,6 @@ private static class Snippets {
258258
// empty
259259
}
260260

261-
@CucumberOptions(strict = true)
262-
private static class Strict {
263-
// empty
264-
}
265-
266-
@CucumberOptions
267-
private static class NotStrict {
268-
// empty
269-
}
270-
271261
@CucumberOptions(name = { "name1", "name2" })
272262
private static class MultipleNames {
273263
// empty
@@ -387,11 +377,6 @@ public boolean dryRun() {
387377
return annotation.dryRun();
388378
}
389379

390-
@Override
391-
public boolean strict() {
392-
return annotation.strict();
393-
}
394-
395380
@Override
396381
public String[] features() {
397382
return annotation.features();

core/src/test/java/io/cucumber/core/plugin/StatsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void should_print_failed_ambiguous_scenarios() {
207207
}
208208

209209
@Test
210-
void should_print_failed_ambiguous_pending_undefined_scenarios_if_strict() {
210+
void should_print_failed_ambiguous_pending_undefined_scenarios() {
211211
Stats counter = createMonochromeSummaryCounter();
212212
ByteArrayOutputStream baos = new ByteArrayOutputStream();
213213

0 commit comments

Comments
 (0)