Skip to content

[Core] Remove --strict and --no-strict options #2275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Deprecated

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

### Fixed

Expand Down
2 changes: 0 additions & 2 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ cucumber.execution.limit= # number of scenarios to execute (CLI only).

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

cucumber.execution.strict= # true or false. default: false.

cucumber.execution.wip= # true or false. default: false.
# Fails if there any passing scenarios
# CLI only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ public final class CommandlineOptions {
public static final String DRY_RUN = "--dry-run";
public static final String DRY_RUN_SHORT = "-d";

public static final String NO_STRICT = "--no-strict";

public static final String STRICT = "--strict";
public static final String STRICT_SHORT = "-s";

public static final String NO_MONOCHROME = "--no-monochrome";

public static final String MONOCHROME = "--monochrome";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,13 @@
import static io.cucumber.core.cli.CommandlineOptions.NAME_SHORT;
import static io.cucumber.core.cli.CommandlineOptions.NO_DRY_RUN;
import static io.cucumber.core.cli.CommandlineOptions.NO_MONOCHROME;
import static io.cucumber.core.cli.CommandlineOptions.NO_STRICT;
import static io.cucumber.core.cli.CommandlineOptions.NO_SUMMARY;
import static io.cucumber.core.cli.CommandlineOptions.OBJECT_FACTORY;
import static io.cucumber.core.cli.CommandlineOptions.ORDER;
import static io.cucumber.core.cli.CommandlineOptions.PLUGIN;
import static io.cucumber.core.cli.CommandlineOptions.PLUGIN_SHORT;
import static io.cucumber.core.cli.CommandlineOptions.PUBLISH;
import static io.cucumber.core.cli.CommandlineOptions.SNIPPETS;
import static io.cucumber.core.cli.CommandlineOptions.STRICT;
import static io.cucumber.core.cli.CommandlineOptions.STRICT_SHORT;
import static io.cucumber.core.cli.CommandlineOptions.TAGS;
import static io.cucumber.core.cli.CommandlineOptions.TAGS_SHORT;
import static io.cucumber.core.cli.CommandlineOptions.THREADS;
Expand Down Expand Up @@ -141,14 +138,8 @@ private RuntimeOptionsBuilder parse(List<String> args) {
parsedOptions.setDryRun(true);
} else if (arg.equals(NO_DRY_RUN)) {
parsedOptions.setDryRun(false);
} else if (arg.equals(NO_STRICT)) {
out.println("--no-strict is no longer effective");
exitCode = 1;
return parsedOptions;
} else if (arg.equals(NO_SUMMARY)) {
parsedOptions.setNoSummary();
} else if (arg.equals(STRICT) || arg.equals(STRICT_SHORT)) {
log.warn(() -> "--strict is enabled by default. This option will be removed in a future release.");
} else if (arg.equals(MONOCHROME) || arg.equals(MONOCHROME_SHORT)) {
parsedOptions.setMonochrome(true);
} else if (arg.equals(NO_MONOCHROME)) {
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/java/io/cucumber/core/options/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ public final class Constants {
*/
public static final String EXECUTION_ORDER_PROPERTY_NAME = "cucumber.execution.order";

/**
* Property name used to disable strict execution: {@value}
* <p>
* When using strict execution Cucumber will treat undefined and pending
* steps as errors.
* <p>
* By default, strict execution is enabled.
*/
public static final String EXECUTION_STRICT_PROPERTY_NAME = "cucumber.execution.strict";

/**
* Property name used to enable wip execution: {@value}
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public RuntimeOptionsBuilder parse(Class<?> clazz) {
addTags(classWithOptions, options, args);
addPlugins(options, args);
addPublish(options, args);
addStrict(options, args);
addName(options, args);
addSnippets(options, args);
addGlue(options, args);
Expand Down Expand Up @@ -94,13 +93,6 @@ private void addPublish(CucumberOptions options, RuntimeOptionsBuilder args) {
}
}

private void addStrict(CucumberOptions options, RuntimeOptionsBuilder args) {
if (!options.strict()) {
throw new CucumberException(
"@CucumberOptions(strict=false) is no longer supported. Please use strict=true");
}
}

private void addName(CucumberOptions options, RuntimeOptionsBuilder args) {
for (String name : options.name()) {
Pattern pattern = Pattern.compile(name);
Expand Down Expand Up @@ -196,8 +188,6 @@ public interface CucumberOptions {

boolean dryRun();

boolean strict();

String[] features();

String[] glue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static io.cucumber.core.options.Constants.EXECUTION_DRY_RUN_PROPERTY_NAME;
import static io.cucumber.core.options.Constants.EXECUTION_LIMIT_PROPERTY_NAME;
import static io.cucumber.core.options.Constants.EXECUTION_ORDER_PROPERTY_NAME;
import static io.cucumber.core.options.Constants.EXECUTION_STRICT_PROPERTY_NAME;
import static io.cucumber.core.options.Constants.FEATURES_PROPERTY_NAME;
import static io.cucumber.core.options.Constants.FILTER_NAME_PROPERTY_NAME;
import static io.cucumber.core.options.Constants.FILTER_TAGS_PROPERTY_NAME;
Expand Down Expand Up @@ -60,11 +59,6 @@ public RuntimeOptionsBuilder parse(Map<String, String> properties) {
PickleOrderParser::parse,
builder::setPickleOrder);

parse(properties,
EXECUTION_STRICT_PROPERTY_NAME,
BooleanString::parseBoolean,
CucumberPropertiesParser::errorOnNonStrict);

parseAll(properties,
FEATURES_PROPERTY_NAME,
splitAndThenFlatMap(CucumberPropertiesParser::parseFeatureFile),
Expand Down Expand Up @@ -134,13 +128,6 @@ private <T> void parse(
parseAll(properties, propertyName, parser.andThen(Collections::singletonList), setter);
}

private static void errorOnNonStrict(Boolean strict) {
if (!strict) {
throw new CucumberException(EXECUTION_STRICT_PROPERTY_NAME
+ "=false is no longer effective. Please use =true (the default) or remove this property");
}
}

private <T> void parseAll(
Map<String, String> properties, String propertyName, Function<String, Collection<T>> parser,
Consumer<T> setter
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/resources/io/cucumber/core/options/USAGE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ cucumber.execution.limit= # number of scenarios to execute (CLI only).

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

cucumber.execution.strict= # true or false. default: false.

cucumber.execution.wip= # true or false. default: false.
# Fails if there any passing scenarios
# CLI only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void set_monochrome_on_color_aware_formatters() {
@Test
void set_strict_on_strict_aware_formatters() {
RuntimeOptions options = parser
.parse("--strict", "--plugin", AwareFormatter.class.getName())
.parse("--plugin", AwareFormatter.class.getName())
.build();
Plugins plugins = new Plugins(new PluginFactory(), options);
plugins.setEventBusOnEventListenerPlugins(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

boolean dryRun() default false;

boolean strict() default true;

String[] features() default {};

String[] glue() default {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,6 @@ private static class Snippets {
// empty
}

@CucumberOptions(strict = true)
private static class Strict {
// empty
}

@CucumberOptions
private static class NotStrict {
// empty
}

@CucumberOptions(name = { "name1", "name2" })
private static class MultipleNames {
// empty
Expand Down Expand Up @@ -387,11 +377,6 @@ public boolean dryRun() {
return annotation.dryRun();
}

@Override
public boolean strict() {
return annotation.strict();
}

@Override
public String[] features() {
return annotation.features();
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/java/io/cucumber/core/plugin/StatsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void should_print_failed_ambiguous_scenarios() {
}

@Test
void should_print_failed_ambiguous_pending_undefined_scenarios_if_strict() {
void should_print_failed_ambiguous_pending_undefined_scenarios() {
Stats counter = createMonochromeSummaryCounter();
ByteArrayOutputStream baos = new ByteArrayOutputStream();

Expand Down
Loading