diff --git a/.github/scripts/update_renovate_changelogs.py b/.github/scripts/update_renovate_changelogs.py index 21698f0307..11b09b7002 100755 --- a/.github/scripts/update_renovate_changelogs.py +++ b/.github/scripts/update_renovate_changelogs.py @@ -18,7 +18,7 @@ ("libraries", "diktat-runner"): "diktat", ("libraries", "flexmark-all"): "flexmark", ("libraries", "freshmark"): "freshmark", - ("libraries", "gherkin-utils"): "gherkin-utils", + ("libraries", "gherkin-formatter"): "gherkin-formatter", ("libraries", "google-java-format"): "google-java-format", ("libraries", "gson"): "gson", ("libraries", "json-simple"): "json-simple", diff --git a/CHANGES.md b/CHANGES.md index 5a3c98ad78..30eff8d313 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Fixed - Fix npm/node executable discovery treating a directory (e.g. an `npm` folder inside `NODE_PATH`) as an executable. ([#3190](https://github.com/diffplug/spotless/issues/3190)) +### Changes +- Replace `gherkin-utils` with `gherkin-formatter`. ([#3217](https://github.com/diffplug/spotless/issues/3217)) + ## [4.12.0] - 2026-11-21 ### Changes - Bump default `adocfmt` version `0.3.1` -> `0.3.2`. ([#3180](https://github.com/diffplug/spotless/pull/3180)) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1823b87cf1..6d77399003 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -51,7 +51,7 @@ diktat-runner = "com.saveourtool.diktat:diktat-runner:2.0.0" flexmark-all = "com.vladsch.flexmark:flexmark-all:0.64.8" freshmark = "com.diffplug.freshmark:freshmark:1.3.1" cucumber-gherkin = "io.cucumber:gherkin:43.0.0" -gherkin-utils = "io.cucumber:gherkin-utils:12.0.2" +gherkin-formatter = "io.cucumber:gherkin-formatter:0.1.0" google-java-format = "com.google.googlejavaformat:google-java-format:2.0.0" gson = "com.google.code.gson:gson:2.15.0" json-simple = "org.json:json:20210307" diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 1e7f44de8c..6ae87a6411 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -33,7 +33,7 @@ buildConfig { buildConfigField("VERSION_ADOCFMT", libs.adocfmt.version) } forClass("com.diffplug.spotless.gherkin", "GherkinBuildConfig") { - buildConfigField("VERSION_GHERKIN_UTILS", libs.gherkin.utils.version) + buildConfigField("VERSION_GHERKIN_FORMATTER", libs.gherkin.formatter.version) buildConfigField("VERSION_GHERKIN", libs.cucumber.gherkin.version) } forClass("com.diffplug.spotless.json", "JsonBuildConfig") { @@ -149,7 +149,7 @@ dependencies { // flexmark "flexmarkCompileOnly"(libs.flexmark.all) // gherkin - "gherkinCompileOnly"(libs.gherkin.utils) + "gherkinCompileOnly"(libs.gherkin.formatter) "gherkinCompileOnly"(libs.cucumber.gherkin) "gherkinCompileOnly"(libs.slf4j.api) // googleJavaFormat diff --git a/lib/src/gherkin/java/com/diffplug/spotless/glue/gherkin/GherkinUtilsFormatterFunc.java b/lib/src/gherkin/java/com/diffplug/spotless/glue/gherkin/GherkinFormatterFormatterFunc.java similarity index 69% rename from lib/src/gherkin/java/com/diffplug/spotless/glue/gherkin/GherkinUtilsFormatterFunc.java rename to lib/src/gherkin/java/com/diffplug/spotless/glue/gherkin/GherkinFormatterFormatterFunc.java index 0bdaf2660b..6cd3c9bd38 100644 --- a/lib/src/gherkin/java/com/diffplug/spotless/glue/gherkin/GherkinUtilsFormatterFunc.java +++ b/lib/src/gherkin/java/com/diffplug/spotless/glue/gherkin/GherkinFormatterFormatterFunc.java @@ -19,30 +19,33 @@ import org.slf4j.LoggerFactory; import com.diffplug.spotless.FormatterFunc; -import com.diffplug.spotless.gherkin.GherkinUtilsConfig; +import com.diffplug.spotless.gherkin.GherkinFormatterConfig; import io.cucumber.gherkin.GherkinParser; -import io.cucumber.gherkin.utils.pretty.Pretty; -import io.cucumber.gherkin.utils.pretty.Syntax; +import io.cucumber.gherkin.formatter.GherkinDocumentFormatter; import io.cucumber.messages.types.Envelope; import io.cucumber.messages.types.GherkinDocument; import io.cucumber.messages.types.Source; import io.cucumber.messages.types.SourceMediaType; -public class GherkinUtilsFormatterFunc implements FormatterFunc { - private static final Logger LOGGER = LoggerFactory.getLogger(GherkinUtilsFormatterFunc.class); +public class GherkinFormatterFormatterFunc implements FormatterFunc { + private static final Logger LOGGER = LoggerFactory.getLogger(GherkinFormatterFormatterFunc.class); - private final GherkinUtilsConfig gherkinSimpleConfig; + private final GherkinDocumentFormatter formatter; - public GherkinUtilsFormatterFunc(GherkinUtilsConfig gherkinSimpleConfig) { - this.gherkinSimpleConfig = gherkinSimpleConfig; + public GherkinFormatterFormatterFunc(GherkinFormatterConfig gherkinSimpleConfig) { + this.formatter = GherkinDocumentFormatter.builder() + .indentation(" ".repeat(gherkinSimpleConfig.getIndentSpaces())) + .build(); + ; } - // Follows https://github.com/cucumber/gherkin-utils/blob/main/java/src/test/java/io/cucumber/gherkin/utils/pretty/PrettyTest.java + // Follows https://github.com/cucumber/gherkin-formatter/tree/main/java#usage private GherkinDocument parse(String gherkin) { GherkinParser parser = GherkinParser .builder() .includeSource(false) + .includePickles(false) .build(); return parser.parse(Envelope.of(new Source("test.feature", gherkin, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN))) .findFirst() @@ -53,8 +56,6 @@ private GherkinDocument parse(String gherkin) { @Override public String apply(String inputString) { - GherkinDocument gherkinDocument = parse(inputString); - - return Pretty.prettyPrint(gherkinDocument, Syntax.gherkin); + return formatter.format(parse(inputString)); } } diff --git a/lib/src/main/java/com/diffplug/spotless/gherkin/GherkinUtilsConfig.java b/lib/src/main/java/com/diffplug/spotless/gherkin/GherkinFormatterConfig.java similarity index 87% rename from lib/src/main/java/com/diffplug/spotless/gherkin/GherkinUtilsConfig.java rename to lib/src/main/java/com/diffplug/spotless/gherkin/GherkinFormatterConfig.java index 2b499f1f18..fba90c0ff4 100644 --- a/lib/src/main/java/com/diffplug/spotless/gherkin/GherkinUtilsConfig.java +++ b/lib/src/main/java/com/diffplug/spotless/gherkin/GherkinFormatterConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2025 DiffPlug + * Copyright 2023-2026 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ import java.io.Serial; import java.io.Serializable; -public class GherkinUtilsConfig implements Serializable { +public class GherkinFormatterConfig implements Serializable { @Serial private static final long serialVersionUID = 1L; @@ -30,7 +30,7 @@ public static int defaultIndentSpaces() { final int indentSpaces; - public GherkinUtilsConfig(int indentSpaces) { + public GherkinFormatterConfig(int indentSpaces) { this.indentSpaces = indentSpaces; } diff --git a/lib/src/main/java/com/diffplug/spotless/gherkin/GherkinUtilsStep.java b/lib/src/main/java/com/diffplug/spotless/gherkin/GherkinFormatterStep.java similarity index 73% rename from lib/src/main/java/com/diffplug/spotless/gherkin/GherkinUtilsStep.java rename to lib/src/main/java/com/diffplug/spotless/gherkin/GherkinFormatterStep.java index fb30afe1d2..607752560b 100644 --- a/lib/src/main/java/com/diffplug/spotless/gherkin/GherkinUtilsStep.java +++ b/lib/src/main/java/com/diffplug/spotless/gherkin/GherkinFormatterStep.java @@ -27,35 +27,35 @@ import com.diffplug.spotless.JarState; import com.diffplug.spotless.Provisioner; -public final class GherkinUtilsStep implements Serializable { +public final class GherkinFormatterStep implements Serializable { @Serial private static final long serialVersionUID = 1L; - private static final String MAVEN_COORDINATE = "io.cucumber:gherkin-utils:"; + private static final String MAVEN_COORDINATE = "io.cucumber:gherkin-formatter:"; private static final String GHERKIN_MAVEN_COORDINATE = "io.cucumber:gherkin:"; - public static final String NAME = "gherkinUtils"; + public static final String NAME = "gherkinFormatter"; private final JarState.Promised jarState; - private final GherkinUtilsConfig gherkinSimpleConfig; + private final GherkinFormatterConfig gherkinSimpleConfig; - private GherkinUtilsStep(JarState.Promised jarState, GherkinUtilsConfig gherkinSimpleConfig) { + private GherkinFormatterStep(JarState.Promised jarState, GherkinFormatterConfig gherkinSimpleConfig) { this.jarState = jarState; this.gherkinSimpleConfig = gherkinSimpleConfig; } public static String defaultVersion() { - return GherkinBuildConfig.VERSION_GHERKIN_UTILS; + return GherkinBuildConfig.VERSION_GHERKIN_FORMATTER; } - public static FormatterStep create(GherkinUtilsConfig gherkinSimpleConfig, + public static FormatterStep create(GherkinFormatterConfig gherkinSimpleConfig, String formatterVersion, Provisioner provisioner) { Objects.requireNonNull(provisioner, "provisioner cannot be null"); List coordinates = List.of( MAVEN_COORDINATE + formatterVersion, GHERKIN_MAVEN_COORDINATE + GherkinBuildConfig.VERSION_GHERKIN); return FormatterStep.create(NAME, - new GherkinUtilsStep(JarState.promise(() -> JarState.from(coordinates, provisioner)), gherkinSimpleConfig), - GherkinUtilsStep::equalityState, - GherkinUtilsStep.State::toFormatter); + new GherkinFormatterStep(JarState.promise(() -> JarState.from(coordinates, provisioner)), gherkinSimpleConfig), + GherkinFormatterStep::equalityState, + GherkinFormatterStep.State::toFormatter); } private State equalityState() { @@ -66,18 +66,18 @@ private static final class State implements Serializable { @Serial private static final long serialVersionUID = 1L; - private final GherkinUtilsConfig gherkinSimpleConfig; + private final GherkinFormatterConfig gherkinSimpleConfig; private final JarState jarState; - State(JarState jarState, GherkinUtilsConfig gherkinSimpleConfig) { + State(JarState jarState, GherkinFormatterConfig gherkinSimpleConfig) { this.jarState = jarState; this.gherkinSimpleConfig = gherkinSimpleConfig; } FormatterFunc toFormatter() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { - Class formatterFunc = jarState.getClassLoader().loadClass("com.diffplug.spotless.glue.gherkin.GherkinUtilsFormatterFunc"); - Constructor constructor = formatterFunc.getConstructor(GherkinUtilsConfig.class); + Class formatterFunc = jarState.getClassLoader().loadClass("com.diffplug.spotless.glue.gherkin.GherkinFormatterFormatterFunc"); + Constructor constructor = formatterFunc.getConstructor(GherkinFormatterConfig.class); return (FormatterFunc) constructor.newInstance(gherkinSimpleConfig); } } diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 67e6658fad..c5d7cc6632 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -8,6 +8,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( - Fix `Cannot set the value of task ... property 'taskService'` when Spotless is applied to sibling projects but not to their parent, a regression since `8.3.0`. Applying it to the root project with `apply false` is no longer necessary. ([#2877](https://github.com/diffplug/spotless/issues/2877)) ### Changes - README: example for formatting Dockerfiles with prettier and `prettier-plugin-sh`. ([#3158](https://github.com/diffplug/spotless/issues/3158)) +- Replace `gherkinUtils` with `gherkinFormatter`. ([#3217](https://github.com/diffplug/spotless/issues/3217)) ## [8.12.0] - 2026-11-21 ### Added diff --git a/plugin-gradle/README.md b/plugin-gradle/README.md index 82c9dc377c..6dac7b0dee 100644 --- a/plugin-gradle/README.md +++ b/plugin-gradle/README.md @@ -1518,23 +1518,23 @@ spotless { spotless { gherkin { target 'src/**/*.feature' // you have to set the target manually - gherkinUtils() // has its own section below + gherkinFormatter() // has its own section below } } ``` -### gherkinUtils +### gherkinFormatter -[homepage](https://github.com/cucumber/gherkin-utils). [changelog](https://github.com/cucumber/gherkin-utils/blob/main/CHANGELOG.md). +[homepage](https://github.com/cucumber/gherkin-formatter). [changelog](https://github.com/cucumber/gherkin-formatter/blob/main/CHANGELOG.md). -Uses a Gherkin pretty-printer that optionally allows configuring the number of spaces that are used to pretty print objects: +Uses a Gherkin document formatter that optionally allows configuring the number of spaces that are used to pretty print objects: ```gradle spotless { gherkin { target 'src/**/*.feature' // required to be set explicitly - gherkinUtils() - .version('9.0.0') // optional: custom version of 'io.cucumber:gherkin-utils' + gherkinFormatter() + .version('0.1.0') // optional: custom version of 'io.cucumber:gherkin-formatter' } } ``` diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GherkinExtension.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GherkinExtension.java index 6305289818..0c6c9c2501 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GherkinExtension.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GherkinExtension.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 DiffPlug + * Copyright 2016-2026 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ import javax.inject.Inject; import com.diffplug.spotless.FormatterStep; -import com.diffplug.spotless.gherkin.GherkinUtilsStep; +import com.diffplug.spotless.gherkin.GherkinFormatterStep; public class GherkinExtension extends FormatExtension { static final String NAME = "gherkin"; @@ -36,17 +36,17 @@ protected void setupTask(SpotlessTask task) { super.setupTask(task); } - public GherkinUtilsConfig gherkinUtils() { - return new GherkinUtilsConfig(); + public GherkinFormatterConfig gherkinFormatter() { + return new GherkinFormatterConfig(); } - public class GherkinUtilsConfig { + public class GherkinFormatterConfig { private String version; private int indent; - public GherkinUtilsConfig() { - this.version = GherkinUtilsStep.defaultVersion(); - this.indent = com.diffplug.spotless.gherkin.GherkinUtilsConfig.defaultIndentSpaces(); + public GherkinFormatterConfig() { + this.version = GherkinFormatterStep.defaultVersion(); + this.indent = com.diffplug.spotless.gherkin.GherkinFormatterConfig.defaultIndentSpaces(); addStep(createStep()); } @@ -56,7 +56,7 @@ public void version(String version) { } private FormatterStep createStep() { - return GherkinUtilsStep.create(new com.diffplug.spotless.gherkin.GherkinUtilsConfig(indent), version, provisioner()); + return GherkinFormatterStep.create(new com.diffplug.spotless.gherkin.GherkinFormatterConfig(indent), version, provisioner()); } } diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GherkinExtensionTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GherkinExtensionTest.java index b78094cf18..f3d19454e4 100644 --- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GherkinExtensionTest.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GherkinExtensionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 DiffPlug + * Copyright 2021-2026 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public void defaultFormatting() throws IOException { "spotless {", " gherkin {", " target 'examples/**/*.feature'", - " gherkinUtils()", + " gherkinFormatter()", " }", "}"); setFile("src/main/resources/example.feature").toResource("gherkin/minimalBefore.feature"); diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index ff78402409..404c36326f 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -7,6 +7,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( - Fix npm/node executable discovery treating a directory (e.g. an `npm` folder inside `NODE_PATH`) as an executable. ([#3190](https://github.com/diffplug/spotless/issues/3190)) ### Changes - README: example for formatting Dockerfiles with prettier and `prettier-plugin-sh`. ([#3158](https://github.com/diffplug/spotless/issues/3158)) +- Replace `gherkinUtils` with `gherkinFormatter`. ([#3217](https://github.com/diffplug/spotless/issues/3217)) ## [3.12.0] - 2026-11-21 ### Changes diff --git a/plugin-maven/README.md b/plugin-maven/README.md index e4b97e5ddb..998b08b4ae 100644 --- a/plugin-maven/README.md +++ b/plugin-maven/README.md @@ -1434,21 +1434,21 @@ When formatting shell scripts via `shfmt`, configure `shfmt` settings via `.edit src/**/*.feature - + ``` -### gherkinUtils +### gherkinFormatter -[homepage](https://github.com/cucumber/gherkin-utils). [changelog](https://github.com/cucumber/gherkin-utils/blob/main/CHANGELOG.md). +[homepage](https://github.com/cucumber/gherkin-formatter). [changelog](https://github.com/cucumber/gherkin-formatter/blob/main/CHANGELOG.md). -Uses a Gherkin pretty-printer that optionally allows configuring the number of spaces that are used to pretty print objects: +Uses a Gherkin document formatter that optionally allows configuring the number of spaces that are used to pretty print documents: ```xml - - 9.0.0 - + + 0.1.0 + ``` ## Go diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/Gherkin.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/Gherkin.java index 60181d048a..801fd09a08 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/Gherkin.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/Gherkin.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 DiffPlug + * Copyright 2023-2026 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,8 +36,8 @@ public String licenseHeaderDelimiter() { return null; } - public void addGherkinUtils(GherkinUtils gherkinUtils) { - addStepFactory(gherkinUtils); + public void addGherkinFormatter(GherkinFormatter gherkinFormatter) { + addStepFactory(gherkinFormatter); } } diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/GherkinUtils.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/GherkinFormatter.java similarity index 65% rename from plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/GherkinUtils.java rename to plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/GherkinFormatter.java index 2eeabb9ab5..9285f26cb4 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/GherkinUtils.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/GherkinFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 DiffPlug + * Copyright 2023-2026 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,25 +18,24 @@ import org.apache.maven.plugins.annotations.Parameter; import com.diffplug.spotless.FormatterStep; -import com.diffplug.spotless.gherkin.GherkinUtilsConfig; -import com.diffplug.spotless.gherkin.GherkinUtilsStep; +import com.diffplug.spotless.gherkin.GherkinFormatterStep; import com.diffplug.spotless.maven.FormatterFactory; import com.diffplug.spotless.maven.FormatterStepConfig; import com.diffplug.spotless.maven.FormatterStepFactory; /** - * A {@link FormatterFactory} implementation that corresponds to {@code ...} configuration element. + * A {@link FormatterFactory} implementation that corresponds to {@code ...} configuration element. */ -public class GherkinUtils implements FormatterStepFactory { +public class GherkinFormatter implements FormatterStepFactory { @Parameter - private String version = GherkinUtilsStep.defaultVersion(); + private String version = GherkinFormatterStep.defaultVersion(); @Parameter - private int indentWithSpaces = GherkinUtilsConfig.defaultIndentSpaces(); + private int indentWithSpaces = com.diffplug.spotless.gherkin.GherkinFormatterConfig.defaultIndentSpaces(); @Override public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) { - return GherkinUtilsStep.create(new GherkinUtilsConfig(indentWithSpaces), version, stepConfig.getProvisioner()); + return GherkinFormatterStep.create(new com.diffplug.spotless.gherkin.GherkinFormatterConfig(indentWithSpaces), version, stepConfig.getProvisioner()); } } diff --git a/testlib/src/main/resources/gherkin/complex_backgroundAfter.feature b/testlib/src/main/resources/gherkin/complex_backgroundAfter.feature index eb4d4de89a..3a40bdf1a6 100644 --- a/testlib/src/main/resources/gherkin/complex_backgroundAfter.feature +++ b/testlib/src/main/resources/gherkin/complex_backgroundAfter.feature @@ -1,4 +1,5 @@ Feature: Complex background + We want to ensure PickleStep all have different IDs Background: a simple background @@ -20,5 +21,5 @@ Feature: Complex background Examples: | value | - | 1 | - | 2 | + | 1 | + | 2 | diff --git a/testlib/src/main/resources/gherkin/descriptionsAfter.feature b/testlib/src/main/resources/gherkin/descriptionsAfter.feature index 897133527d..a794289c70 100644 --- a/testlib/src/main/resources/gherkin/descriptionsAfter.feature +++ b/testlib/src/main/resources/gherkin/descriptionsAfter.feature @@ -1,55 +1,66 @@ Feature: Descriptions everywhere + This is a single line description Scenario: two lines - This description - has two lines and indented with two spaces + + This description + has two lines and indented with two spaces Given the minimalism Scenario: without indentation -This is a description without indentation + + This is a description without indentation Given the minimalism Scenario: empty lines in the middle - This description - has an empty line in the middle + This description + + has an empty line in the middle Given the minimalism Scenario: empty lines around - This description - has an empty lines around + + This description + has an empty lines around Given the minimalism Scenario: comment after description - This description - has a comment after - # this is a comment + This description + has a comment after + + # this is a comment Given the minimalism Scenario: comment right after description - This description - has a comment right after + + This description + has a comment right after # this is another comment Given the minimalism Scenario: description with escaped docstring separator - This description has an \"\"\" (escaped docstring sparator) + + This description has an \"\"\" (escaped docstring sparator) Given the minimalism Scenario Outline: scenario outline with a description -This is a scenario outline description + + This is a scenario outline description Given the minimalism Examples: examples with description -This is an examples description + + This is an examples description + | foo | | bar | diff --git a/testlib/src/main/resources/gherkin/rule_with_tagAfter.feature b/testlib/src/main/resources/gherkin/rule_with_tagAfter.feature index bba6b044ac..b184e8c24f 100644 --- a/testlib/src/main/resources/gherkin/rule_with_tagAfter.feature +++ b/testlib/src/main/resources/gherkin/rule_with_tagAfter.feature @@ -2,14 +2,16 @@ Feature: Some tagged rules Rule: Untagged rule - The untagged rule description + + The untagged rule description Scenario: Scenario with only a feature tag Given a @tag_rule Rule: Tagged rule - The tagged rule description + + The tagged rule description Scenario: Scenario with feature and rule tags Given b diff --git a/testlib/src/test/java/com/diffplug/spotless/gherkin/GherkinUtilsStepTest.java b/testlib/src/test/java/com/diffplug/spotless/gherkin/GherkinFormatterStepTest.java similarity index 75% rename from testlib/src/test/java/com/diffplug/spotless/gherkin/GherkinUtilsStepTest.java rename to testlib/src/test/java/com/diffplug/spotless/gherkin/GherkinFormatterStepTest.java index c9ccf15fb1..f17b7f1caa 100644 --- a/testlib/src/test/java/com/diffplug/spotless/gherkin/GherkinUtilsStepTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/gherkin/GherkinFormatterStepTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 DiffPlug + * Copyright 2021-2026 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,17 +25,17 @@ import com.diffplug.spotless.StepHarness; import com.diffplug.spotless.TestProvisioner; -public class GherkinUtilsStepTest { +public class GherkinFormatterStepTest { - private static final String VERSION = GherkinUtilsStep.defaultVersion(); - private static final int INDENT = GherkinUtilsConfig.defaultIndentSpaces(); + private static final String VERSION = GherkinFormatterStep.defaultVersion(); + private static final int INDENT = GherkinFormatterConfig.defaultIndentSpaces(); - private final FormatterStep step = GherkinUtilsStep.create(new GherkinUtilsConfig(INDENT), VERSION, TestProvisioner.mavenCentral()); + private final FormatterStep step = GherkinFormatterStep.create(new GherkinFormatterConfig(INDENT), VERSION, TestProvisioner.mavenCentral()); private final StepHarness stepHarness = StepHarness.forStep(step); @Test public void cannotProvidedNullProvisioner() { - assertThatThrownBy(() -> GherkinUtilsStep.create(new GherkinUtilsConfig(INDENT), VERSION, null)).isInstanceOf(NullPointerException.class).hasMessage("provisioner cannot be null"); + assertThatThrownBy(() -> GherkinFormatterStep.create(new GherkinFormatterConfig(INDENT), VERSION, null)).isInstanceOf(NullPointerException.class).hasMessage("provisioner cannot be null"); } @Test @@ -72,10 +72,9 @@ public void handlesNotGherkin() { .hasMessage("No gherkin document"); } - @Disabled("gherkin-utils does not allow custom indentation") @Test public void canSetCustomIndentationLevel() throws Exception { - FormatterStep step = GherkinUtilsStep.create(new GherkinUtilsConfig(6), VERSION, TestProvisioner.mavenCentral()); + FormatterStep step = GherkinFormatterStep.create(new GherkinFormatterConfig(6), VERSION, TestProvisioner.mavenCentral()); StepHarness stepHarness = StepHarness.forStep(step); String before = "gherkin/minimalBefore.feature"; @@ -83,10 +82,10 @@ public void canSetCustomIndentationLevel() throws Exception { stepHarness.testResource(before, after); } - @Disabled("gherkin-utils does not allow custom indentation") + @Disabled("gherkin-formatter does not allow 0 indentation") @Test public void canSetIndentationLevelTo0() throws Exception { - FormatterStep step = GherkinUtilsStep.create(new GherkinUtilsConfig(0), VERSION, TestProvisioner.mavenCentral()); + FormatterStep step = GherkinFormatterStep.create(new GherkinFormatterConfig(0), VERSION, TestProvisioner.mavenCentral()); StepHarness stepHarness = StepHarness.forStep(step); String before = "gherkin/minimalBefore.feature"; @@ -111,7 +110,7 @@ protected void setupTest(API api) { @Override protected FormatterStep create() { - return GherkinUtilsStep.create(new GherkinUtilsConfig(spaces), VERSION, TestProvisioner.mavenCentral()); + return GherkinFormatterStep.create(new GherkinFormatterConfig(spaces), VERSION, TestProvisioner.mavenCentral()); } }.testEquals(); }