From abc717e1ad4e96aa630bcfa254789d87a8b33584 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 22 Apr 2023 04:07:04 +0000 Subject: [PATCH 01/18] Update dependency org.apache.maven.plugins:maven-surefire-plugin to v3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 445df6b..838c164 100644 --- a/pom.xml +++ b/pom.xml @@ -124,7 +124,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.0.0 -Duser.language=en -Xmx1024m From 2e98df3c2cd0bc7bb9229540e89703da6bc9982f Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 17:37:55 +0800 Subject: [PATCH 02/18] bump version to 7.0.0-SNAPSHOT to align with cucumber 7.x versions --- examples/pom.xml | 2 +- groovy/pom.xml | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index 87ed33a..5e31077 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -4,7 +4,7 @@ io.cucumber cucumber-jvm-groovy - 6.10.5-SNAPSHOT + 7.0.0-SNAPSHOT groovy-examples diff --git a/groovy/pom.xml b/groovy/pom.xml index 56dcfba..3bfe07f 100644 --- a/groovy/pom.xml +++ b/groovy/pom.xml @@ -4,7 +4,7 @@ io.cucumber cucumber-jvm-groovy - 6.10.5-SNAPSHOT + 7.0.0-SNAPSHOT cucumber-groovy diff --git a/pom.xml b/pom.xml index 606786d..a35a0be 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 cucumber-jvm-groovy - 6.10.5-SNAPSHOT + 7.0.0-SNAPSHOT pom Cucumber-JVM: Groovy Cucumber for Groovy From 4153a22c86d0663d02f66200f8ac86c275f3e468 Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 10:41:42 +0800 Subject: [PATCH 03/18] upgrade to latest stable groovy version 4.0.11 --- examples/pom.xml | 4 +++- groovy/pom.xml | 5 +++-- pom.xml | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index 5e31077..df7a169 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -34,8 +34,10 @@ test - org.codehaus.groovy + org.apache.groovy groovy-all + ${groovy.version} + pom provided diff --git a/groovy/pom.xml b/groovy/pom.xml index 3bfe07f..2d17306 100644 --- a/groovy/pom.xml +++ b/groovy/pom.xml @@ -23,8 +23,9 @@ cucumber-core - org.codehaus.groovy + org.apache.groovy groovy-all + pom provided @@ -167,7 +168,7 @@ - + diff --git a/pom.xml b/pom.xml index a35a0be..d00dc32 100644 --- a/pom.xml +++ b/pom.xml @@ -28,9 +28,9 @@ UTF-8 3.3 ${project.build.directory} - 6.11.0 - 18.1.1 - 2.4.21 + 7.11.2 + 26.1.0 + 4.0.11 5.9.2 5.2.0 io.cucumber.groovy @@ -56,9 +56,10 @@ ${cucumber.version} - org.codehaus.groovy + org.apache.groovy groovy-all ${groovy.version} + pom provided @@ -110,9 +111,15 @@ 3.1.0 - org.codehaus.groovy + org.apache.groovy groovy-all ${groovy.version} + pom + + + org.apache.groovy + groovy-ant + ${groovy.version} io.cucumber From 8707db96a5245e6f63ecd4376a3f6fe54c1e19fd Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 10:44:51 +0800 Subject: [PATCH 04/18] package migrated for `GroovyTestCase` to `groovy.test` --- .../src/test/groovy/io/cucumber/groovy/compiled_stepdefs.groovy | 2 +- groovy/src/test/groovy/io/cucumber/groovy/date_stepdefs.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/groovy/src/test/groovy/io/cucumber/groovy/compiled_stepdefs.groovy b/groovy/src/test/groovy/io/cucumber/groovy/compiled_stepdefs.groovy index adfd23e..658a338 100644 --- a/groovy/src/test/groovy/io/cucumber/groovy/compiled_stepdefs.groovy +++ b/groovy/src/test/groovy/io/cucumber/groovy/compiled_stepdefs.groovy @@ -3,7 +3,7 @@ package io.cucumber.groovy import io.cucumber.groovy.EN import io.cucumber.datatable.DataTable -import static groovy.util.GroovyTestCase.assertEquals +import static groovy.test.GroovyTestCase.assertEquals this.metaClass.mixin(EN) this.metaClass.mixin(Hooks) diff --git a/groovy/src/test/groovy/io/cucumber/groovy/date_stepdefs.groovy b/groovy/src/test/groovy/io/cucumber/groovy/date_stepdefs.groovy index 20926df..a4d005d 100644 --- a/groovy/src/test/groovy/io/cucumber/groovy/date_stepdefs.groovy +++ b/groovy/src/test/groovy/io/cucumber/groovy/date_stepdefs.groovy @@ -6,7 +6,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import java.lang.reflect.Type import java.time.LocalDate -import static groovy.util.GroovyTestCase.assertEquals +import static groovy.test.GroovyTestCase.assertEquals this.metaClass.mixin(Hooks) this.metaClass.mixin(EN) From 32ccef58759f3eb4d0a49799851ead8846523592 Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 12:00:13 +0800 Subject: [PATCH 05/18] fix signature change to `io.cucumber.gherkin.GherkinDialectProvider.getDialect()` in https://github.com/cucumber/gherkin/commit/c9357222621a596e6c3ab503ad5de107a408d161#diff-19833f5822cc98daa07bf82eda161651fb9b217038a6c1ba0e4eb50bc467583dL45 --- groovy/src/main/groovy/generate-keywords.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/groovy/src/main/groovy/generate-keywords.groovy b/groovy/src/main/groovy/generate-keywords.groovy index 1f54eaf..b8c907d 100644 --- a/groovy/src/main/groovy/generate-keywords.groovy +++ b/groovy/src/main/groovy/generate-keywords.groovy @@ -8,7 +8,7 @@ def unsupported = ["EM"] // The generated files for Emoij do not compile. def dialectProvider = new GherkinDialectProvider() dialectProvider.getLanguages().each { language -> - def dialect = dialectProvider.getDialect(language, null) + def dialect = dialectProvider.getDialect(language).orElseThrow() def normalized_language = dialect.language.replaceAll("[\\s-]", "_").toUpperCase() if (!unsupported.contains(normalized_language)) { def binding = ["i18n":dialect, "normalized_language":normalized_language] From e90d7a83b316cc0d43f6999b64da6500832fb479 Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 12:13:11 +0800 Subject: [PATCH 06/18] =?UTF-8?q?EN=5FTX=20introduced=20a=20special=20char?= =?UTF-8?q?acter=20=E2=80=99=20or=20'\u2019',=20which=20we=20need=20to=20e?= =?UTF-8?q?scape.=20See:=20https://github.com/cucumber/gherkin/commit/856a?= =?UTF-8?q?4e4b4fef73bba159efc0187f231e7e0e846d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- groovy/src/main/groovy/I18n.groovy.gsp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/groovy/src/main/groovy/I18n.groovy.gsp b/groovy/src/main/groovy/I18n.groovy.gsp index 00833d2..738b821 100644 --- a/groovy/src/main/groovy/I18n.groovy.gsp +++ b/groovy/src/main/groovy/I18n.groovy.gsp @@ -8,23 +8,23 @@ import java.util.regex.Pattern; public class ${normalized_language} { <% i18n.stepKeywords.findAll { !it.contains('*') && !it.matches("^\\d.*") }.unique().each { kw -> %> - public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)}(String[] expressions, Closure body) throws Throwable { + public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!\u2019]", ""), java.text.Normalizer.Form.NFC)}(String[] expressions, Closure body) throws Throwable { Arrays.stream(expressions).forEach(expression-> GroovyBackend.getInstance().addStepDefinition(expression, body) ); } - public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)}(Pattern[] regexps, Closure body) throws Throwable { + public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!\u2019]", ""), java.text.Normalizer.Form.NFC)}(Pattern[] regexps, Closure body) throws Throwable { Arrays.stream(regexps).forEach(regexp-> GroovyBackend.getInstance().addStepDefinition(regexp.toString(), body) ); } - public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)}(String expression, Closure body) throws Throwable { + public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!\u2019]", ""), java.text.Normalizer.Form.NFC)}(String expression, Closure body) throws Throwable { GroovyBackend.getInstance().addStepDefinition(expression, body); } - public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)}(Pattern regexp, Closure body) throws Throwable { + public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!\u2019]", ""), java.text.Normalizer.Form.NFC)}(Pattern regexp, Closure body) throws Throwable { GroovyBackend.getInstance().addStepDefinition(regexp.toString(), body); } <% } %> From c517dad420811dd08bdd5eeaa57eae24558cbdbf Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 12:22:24 +0800 Subject: [PATCH 07/18] I think a test to test "~/^I press (\w+)$/" overloaded by "~/^I have entered (\d+) into .* calculator$/" is no longer required, as Gherkin will not compile duplicated steps like this --- examples/src/test/groovy/calc/CalculatorSteps.groovy | 5 ----- 1 file changed, 5 deletions(-) diff --git a/examples/src/test/groovy/calc/CalculatorSteps.groovy b/examples/src/test/groovy/calc/CalculatorSteps.groovy index ca33548..eada7d2 100644 --- a/examples/src/test/groovy/calc/CalculatorSteps.groovy +++ b/examples/src/test/groovy/calc/CalculatorSteps.groovy @@ -51,11 +51,6 @@ Given(~/^I have entered (\d+) into .* calculator$/) { int number -> calc.push number } -// Remember to still include "->" if there are no parameters. -Given(~/\d+ into the/) {-> - throw new RuntimeException("should never get here since we're running with --guess") -} - // This step calls a Calculator function specified in the step // and saves the result in the current world object. When(~/^I press (\w+)$/) { String opname -> From 78f1c24ce3e714595417f1b6d845d5fb53e97c97 Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 14:04:45 +0800 Subject: [PATCH 08/18] renovate bot left out a place also update the `junit-jupiter.version`? --- examples/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pom.xml b/examples/pom.xml index df7a169..e402f00 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -13,7 +13,7 @@ 1.8 - 5.6.0 + 5.9.2 From 4179475cff4269bb85a0d355dd7296c68bcbe4bc Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 15:12:04 +0800 Subject: [PATCH 09/18] wrapping regexp text with "/", will allow `ExpressionFactory` from `cucumber-expressions` to always pick it up as a regexp as intended. See: https://github.com/cucumber/cucumber-expressions/commit/2ab6baddc52752a7394beb5d46198151f67e4b3a#diff-2362714f85d9eebc65d6f232fc807e5e9706973832e7f70a33a190e7108dbb2cR49 --- groovy/src/main/groovy/I18n.groovy.gsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/groovy/src/main/groovy/I18n.groovy.gsp b/groovy/src/main/groovy/I18n.groovy.gsp index 738b821..a055def 100644 --- a/groovy/src/main/groovy/I18n.groovy.gsp +++ b/groovy/src/main/groovy/I18n.groovy.gsp @@ -16,7 +16,7 @@ public class ${normalized_language} { public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!\u2019]", ""), java.text.Normalizer.Form.NFC)}(Pattern[] regexps, Closure body) throws Throwable { Arrays.stream(regexps).forEach(regexp-> - GroovyBackend.getInstance().addStepDefinition(regexp.toString(), body) + GroovyBackend.getInstance().addStepDefinition("/" + regexp.toString() + "/", body) ); } @@ -25,7 +25,7 @@ public class ${normalized_language} { } public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!\u2019]", ""), java.text.Normalizer.Form.NFC)}(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.getInstance().addStepDefinition(regexp.toString(), body); + GroovyBackend.getInstance().addStepDefinition("/" + regexp.toString() + "/", body); } <% } %> } From 23b8eefe6b97237915737440b5dd3e6136d1be0f Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 16:43:57 +0800 Subject: [PATCH 10/18] `TypeRegistryConfigurer` is no longer supported. Use @DataTableType and @ParameterType instead. See: https://github.com/cucumber/cucumber-jvm/issues/1797 --- .../groovy/TypeRegistryConfiguration.groovy | 60 ------------------- .../cucumber/groovy/compiled_stepdefs.groovy | 13 ++++ .../groovy/io/cucumber/groovy/steps.groovy | 6 -- 3 files changed, 13 insertions(+), 66 deletions(-) delete mode 100644 groovy/src/test/groovy/io/cucumber/groovy/TypeRegistryConfiguration.groovy diff --git a/groovy/src/test/groovy/io/cucumber/groovy/TypeRegistryConfiguration.groovy b/groovy/src/test/groovy/io/cucumber/groovy/TypeRegistryConfiguration.groovy deleted file mode 100644 index 21528c3..0000000 --- a/groovy/src/test/groovy/io/cucumber/groovy/TypeRegistryConfiguration.groovy +++ /dev/null @@ -1,60 +0,0 @@ -package io.cucumber.groovy - - -import io.cucumber.core.api.TypeRegistry -import io.cucumber.core.api.TypeRegistryConfigurer -import io.cucumber.cucumberexpressions.CaptureGroupTransformer -import io.cucumber.cucumberexpressions.ParameterType -import io.cucumber.datatable.DataTableType -import io.cucumber.datatable.TableEntryTransformer - -import java.time.LocalDate - -import static java.util.Locale.ENGLISH - -class TypeRegistryConfiguration implements TypeRegistryConfigurer { - - @Override - Locale locale() { - return ENGLISH - } - - @Override - void configureTypeRegistry(TypeRegistry typeRegistry) { - - final TableEntryTransformer transformer = new TableEntryTransformer() { - @Override - Thing transform(Map tableEntry) { - Thing thing = new Thing() - thing.year = Integer.valueOf(tableEntry.get("year")) - thing.name = tableEntry.get("name") - thing - } - } - typeRegistry.defineDataTableType(new DataTableType(Thing.class, transformer)) - - CaptureGroupTransformer dateTransformer = - { String[] s -> new DateWrapper(date: LocalDate.parse(s[0])) } - - - CaptureGroupTransformer listTransformer = { String[] s -> - return Arrays.asList(s[0].split(","))*.trim() - } - - typeRegistry.defineParameterType(new ParameterType<>( - "date", - "(\\d{4}-\\d{2}-\\d{2})", - DateWrapper.class, - dateTransformer - )) - - typeRegistry.defineParameterType(new ParameterType<>( - "list", - "(.+\\s*,\\s*.+){1,}", - List.class, - listTransformer - )) - } - - -} diff --git a/groovy/src/test/groovy/io/cucumber/groovy/compiled_stepdefs.groovy b/groovy/src/test/groovy/io/cucumber/groovy/compiled_stepdefs.groovy index 658a338..a8c1c63 100644 --- a/groovy/src/test/groovy/io/cucumber/groovy/compiled_stepdefs.groovy +++ b/groovy/src/test/groovy/io/cucumber/groovy/compiled_stepdefs.groovy @@ -19,11 +19,24 @@ Given(~'^I have (\\d+) apples in my belly') { int apples -> Given(~'^a big basket with cukes') { -> } +@DataTableType +Thing dataTableTypeThing(Map tableEntry) { + Thing thing = new Thing() + thing.year = Integer.valueOf(tableEntry.get("year")) + thing.name = tableEntry.get("name") + thing +} + Given(~'^the following table:$') { DataTable table -> things = table.asList(Thing) assertEquals("Cucumber-JVM", things[1].name) } +@ParameterType(name="list", value="(.+\\s*,\\s*.+){1,}") +List parameterTypeList(String[] s) { + Arrays.asList(s[0].split(","))*.trim() +} + Given('this should be converted to a list:{list}') { List list -> assertEquals(3, list.size()) assertEquals("Cucumber-JVM", list.get(0)) diff --git a/groovy/src/test/groovy/io/cucumber/groovy/steps.groovy b/groovy/src/test/groovy/io/cucumber/groovy/steps.groovy index e0b16dd..136605a 100644 --- a/groovy/src/test/groovy/io/cucumber/groovy/steps.groovy +++ b/groovy/src/test/groovy/io/cucumber/groovy/steps.groovy @@ -1,6 +1,5 @@ package io.cucumber.groovy -import io.cucumber.datatable.DataTable import static org.junit.jupiter.api.Assertions.assertEquals import static org.junit.jupiter.api.Assertions.assertTrue @@ -11,11 +10,6 @@ final Author expectedAuthor = new Author("Annie M. G.", "Schmidt", "1911-03-20") final Person expectedPerson = new Person("Astrid", "Lindgren") final Person mononymousPerson = new Person("Plato", "") -@DataTableType -static Author singleAuthorTransformer(DataTable table) { - return authorEntryTransformer(table.asMaps().get(0)) -} - @DataTableType static Author authorEntryTransformer(Map entry) { return new Author( From 2df2f1ae73711128b1c3c8fa6e6095c954c6aa56 Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 17:03:13 +0800 Subject: [PATCH 11/18] use `org.junit.platform.console.ConsoleLauncher` for CLI test instead. See: https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-junit-platform-engine --- groovy/pom.xml | 69 +++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/groovy/pom.xml b/groovy/pom.xml index 2d17306..7d5cffd 100644 --- a/groovy/pom.xml +++ b/groovy/pom.xml @@ -15,6 +15,7 @@ 1.8 2.14.2 5.9.2 + 1.9.2 @@ -51,6 +52,18 @@ ${junit-jupiter.version} test + + io.cucumber + cucumber-junit-platform-engine + ${cucumber.version} + test + + + org.junit.platform + junit-platform-console + ${junit-platform.version} + test + org.mockito mockito-core @@ -140,56 +153,26 @@ - copy-full-jar - package - - - - - - - run - - - - groovy-cli-test + + CLI-test integration-test run - - - - - - - - - - - - - - - - - - + + + + + + - From a9e4df4cecc1566ae73617cabc3346cfa5ecc142 Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 17:07:56 +0800 Subject: [PATCH 12/18] add running test via `junit-platform-suite`. See: https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-junit-platform-engine#suites-with-different-configurations --- groovy/pom.xml | 6 ++++++ .../test/java/io/cucumber/groovy/RunCukesTest.java | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/groovy/pom.xml b/groovy/pom.xml index 7d5cffd..8c058c3 100644 --- a/groovy/pom.xml +++ b/groovy/pom.xml @@ -52,6 +52,12 @@ ${junit-jupiter.version} test + + org.junit.platform + junit-platform-suite + ${junit-platform.version} + test + io.cucumber cucumber-junit-platform-engine diff --git a/groovy/src/test/java/io/cucumber/groovy/RunCukesTest.java b/groovy/src/test/java/io/cucumber/groovy/RunCukesTest.java index 491a748..04e1fe4 100644 --- a/groovy/src/test/java/io/cucumber/groovy/RunCukesTest.java +++ b/groovy/src/test/java/io/cucumber/groovy/RunCukesTest.java @@ -1,9 +1,15 @@ package io.cucumber.groovy; +import org.junit.platform.suite.api.ConfigurationParameter; +import org.junit.platform.suite.api.IncludeEngines; +import org.junit.platform.suite.api.SelectClasspathResource; +import org.junit.platform.suite.api.Suite; -import io.cucumber.junit.Cucumber; -import org.junit.runner.RunWith; +import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME; -@RunWith(Cucumber.class) +@Suite +@IncludeEngines("cucumber") +@SelectClasspathResource("io/cucumber/groovy") +@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "io.cucumber.groovy") public class RunCukesTest { } From c48959ec9561dfc61e16e90a4bbc4129fd58cf07 Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 17:24:09 +0800 Subject: [PATCH 13/18] update `examples` test runner to use latest `cucumber-junit-platform-engine` remove duplicate versions that are already in root pom --- examples/pom.xml | 12 +++++++++--- examples/src/test/java/calc/RunCukesTest.java | 15 ++++++++++----- groovy/pom.xml | 7 ------- pom.xml | 1 + 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index e402f00..31f35c8 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -13,7 +13,6 @@ 1.8 - 5.9.2 @@ -23,8 +22,9 @@ test - io.cucumber - cucumber-junit + org.junit.platform + junit-platform-suite + ${junit-platform.version} test @@ -33,6 +33,12 @@ ${junit-jupiter.version} test + + io.cucumber + cucumber-junit-platform-engine + ${cucumber.version} + test + org.apache.groovy groovy-all diff --git a/examples/src/test/java/calc/RunCukesTest.java b/examples/src/test/java/calc/RunCukesTest.java index c74a78a..26c45f2 100644 --- a/examples/src/test/java/calc/RunCukesTest.java +++ b/examples/src/test/java/calc/RunCukesTest.java @@ -1,11 +1,16 @@ package calc; -import io.cucumber.junit.Cucumber; -import io.cucumber.junit.CucumberOptions; -import org.junit.runner.RunWith; +import org.junit.platform.suite.api.ConfigurationParameter; +import org.junit.platform.suite.api.IncludeEngines; +import org.junit.platform.suite.api.SelectClasspathResource; +import org.junit.platform.suite.api.Suite; -@RunWith(Cucumber.class) -@CucumberOptions(glue = {"calc"} ) +import static io.cucumber.core.options.Constants.GLUE_PROPERTY_NAME; + +@Suite +@IncludeEngines("cucumber") +@SelectClasspathResource("calc") +@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "calc") public class RunCukesTest { } diff --git a/groovy/pom.xml b/groovy/pom.xml index 8c058c3..48638df 100644 --- a/groovy/pom.xml +++ b/groovy/pom.xml @@ -14,8 +14,6 @@ 1.8 2.14.2 - 5.9.2 - 1.9.2 @@ -41,11 +39,6 @@ ${jackson.version} test - - io.cucumber - cucumber-junit - test - org.junit.jupiter junit-jupiter diff --git a/pom.xml b/pom.xml index d00dc32..fe08878 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,7 @@ 26.1.0 4.0.11 5.9.2 + 1.9.2 5.2.0 io.cucumber.groovy From 16140ef011ff3dbb9645b4476daf75e99de5bf4e Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 17:34:25 +0800 Subject: [PATCH 14/18] move `example` to also use gmavenplus-plugin plugin --- examples/pom.xml | 10 +++------- groovy/pom.xml | 2 -- pom.xml | 6 +++--- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index 31f35c8..eb65099 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -11,10 +11,6 @@ jar Cucumber Groovy Examples - - 1.8 - - io.cucumber @@ -51,15 +47,15 @@ - org.codehaus.gmaven - gmaven-plugin + org.codehaus.gmavenplus + gmavenplus-plugin generateStubs compile generateTestStubs - testCompile + compileTests diff --git a/groovy/pom.xml b/groovy/pom.xml index 48638df..5717afd 100644 --- a/groovy/pom.xml +++ b/groovy/pom.xml @@ -12,7 +12,6 @@ Cucumber Groovy - 1.8 2.14.2 @@ -80,7 +79,6 @@ org.codehaus.gmavenplus gmavenplus-plugin - 2.1.0 diff --git a/pom.xml b/pom.xml index fe08878..2a7c44a 100644 --- a/pom.xml +++ b/pom.xml @@ -149,9 +149,9 @@ - org.codehaus.gmaven - gmaven-plugin - 1.5 + org.codehaus.gmavenplus + gmavenplus-plugin + 2.1.0 From 37df5c9e79f5a1dc5d81286020da9ae6e9d25277 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Apr 2023 12:52:46 +0200 Subject: [PATCH 15/18] Housekeeping * Use -bom projects to manage dependencies where possible * Replace JUnit 4 with JUnit 5 --- examples/pom.xml | 7 +--- .../test/resources/junit-platform.properties | 1 + groovy/pom.xml | 39 +++++++++++++++---- .../io/cucumber/groovy/GroovyBackendTest.java | 18 ++++----- .../io/cucumber/groovy/GroovySnippetTest.java | 6 +-- .../cucumber/groovy/GroovyStackTraceTest.java | 25 ++++++------ .../io/cucumber/groovy/GroovyWorldTest.java | 21 +++++----- .../java/io/cucumber/groovy/HooksTest.java | 6 +-- .../java/io/cucumber/groovy/ParallelTest.java | 23 +++++------ .../test/resources/junit-platform.properties | 1 + pom.xml | 39 +++++++------------ 11 files changed, 97 insertions(+), 89 deletions(-) create mode 100644 examples/src/test/resources/junit-platform.properties create mode 100644 groovy/src/test/resources/junit-platform.properties diff --git a/examples/pom.xml b/examples/pom.xml index eb65099..6557b80 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -20,26 +20,21 @@ org.junit.platform junit-platform-suite - ${junit-platform.version} test org.junit.jupiter junit-jupiter - ${junit-jupiter.version} test io.cucumber cucumber-junit-platform-engine - ${cucumber.version} test org.apache.groovy - groovy-all - ${groovy.version} - pom + groovy provided diff --git a/examples/src/test/resources/junit-platform.properties b/examples/src/test/resources/junit-platform.properties new file mode 100644 index 0000000..b48dd63 --- /dev/null +++ b/examples/src/test/resources/junit-platform.properties @@ -0,0 +1 @@ +cucumber.publish.quiet=true diff --git a/groovy/pom.xml b/groovy/pom.xml index 5717afd..fd92805 100644 --- a/groovy/pom.xml +++ b/groovy/pom.xml @@ -13,8 +13,28 @@ 2.14.2 + 5.3.1 + + + + com.fasterxml.jackson + jackson-bom + ${jackson.version} + import + pom + + + org.mockito + mockito-bom + ${mockito.version} + import + pom + + + + io.cucumber @@ -22,44 +42,42 @@ org.apache.groovy - groovy-all - pom + groovy provided + + org.apache.groovy + groovy-test + test + com.fasterxml.jackson.datatype jackson-datatype-jsr310 - ${jackson.version} test com.fasterxml.jackson.core jackson-databind - ${jackson.version} test org.junit.jupiter junit-jupiter - ${junit-jupiter.version} test org.junit.platform junit-platform-suite - ${junit-platform.version} test io.cucumber cucumber-junit-platform-engine - ${cucumber.version} test org.junit.platform junit-platform-console - ${junit-platform.version} test @@ -67,6 +85,11 @@ mockito-core test + + org.mockito + mockito-junit-jupiter + test + com.google.auto.service auto-service diff --git a/groovy/src/test/java/io/cucumber/groovy/GroovyBackendTest.java b/groovy/src/test/java/io/cucumber/groovy/GroovyBackendTest.java index d47274e..4773a82 100644 --- a/groovy/src/test/java/io/cucumber/groovy/GroovyBackendTest.java +++ b/groovy/src/test/java/io/cucumber/groovy/GroovyBackendTest.java @@ -4,18 +4,18 @@ import io.cucumber.core.backend.Container; import io.cucumber.core.backend.Lookup; import org.codehaus.groovy.runtime.MethodClosure; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import java.util.function.Supplier; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class GroovyBackendTest { @Mock Lookup lookup; @@ -29,8 +29,8 @@ public class GroovyBackendTest { @Mock Supplier classLoaderSupplier; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { backend = new GroovyBackend(lookup, container, classLoaderSupplier); } diff --git a/groovy/src/test/java/io/cucumber/groovy/GroovySnippetTest.java b/groovy/src/test/java/io/cucumber/groovy/GroovySnippetTest.java index a1f6c31..173ce12 100644 --- a/groovy/src/test/java/io/cucumber/groovy/GroovySnippetTest.java +++ b/groovy/src/test/java/io/cucumber/groovy/GroovySnippetTest.java @@ -6,13 +6,13 @@ import io.cucumber.core.snippets.SnippetGenerator; import io.cucumber.core.snippets.SnippetType; import io.cucumber.cucumberexpressions.ParameterTypeRegistry; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Collections; import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class GroovySnippetTest { @@ -28,7 +28,7 @@ public void generatesPlainSnippet() { } @Test - public void generatesCopyPasteReadyStepSnippetForNumberParameters() throws Exception { + public void generatesCopyPasteReadyStepSnippetForNumberParameters() { List expected = Collections.singletonList("" + "Given(/before {int} after/) { Integer int1 ->\n" + " // Write code here that turns the phrase above into concrete actions\n" + diff --git a/groovy/src/test/java/io/cucumber/groovy/GroovyStackTraceTest.java b/groovy/src/test/java/io/cucumber/groovy/GroovyStackTraceTest.java index bd0ed81..a9b3019 100644 --- a/groovy/src/test/java/io/cucumber/groovy/GroovyStackTraceTest.java +++ b/groovy/src/test/java/io/cucumber/groovy/GroovyStackTraceTest.java @@ -2,34 +2,35 @@ import groovy.lang.Closure; import org.codehaus.groovy.runtime.MethodClosure; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) +@ExtendWith(MockitoExtension.class) public class GroovyStackTraceTest { GroovyStepDefinition groovyStepDefinition; - @Before - public void setUp() throws Throwable { - Closure body = new MethodClosure("the owner", "length"); + @BeforeEach + public void setUp() { + Closure body = new MethodClosure("the owner", "length"); groovyStepDefinition = new GroovyStepDefinition("", body, null, new ExceptionThrowingBackend()); } @Test - public void should_sanitize_stacktrace() throws Throwable { + public void should_sanitize_stacktrace() { try { groovyStepDefinition.execute(new Object[0]); fail("step definition didn't throw an exception"); } catch (Throwable thrown) { for (StackTraceElement stackTraceElement : thrown.getStackTrace()) { // if there are none of these, pretty good chance it's cleaned up the stack trace - assertFalse("Stack trace has internal groovy callsite elements", stackTraceElement.getClassName().startsWith("org.codehaus.groovy.runtime.callsite")); + assertFalse(stackTraceElement.getClassName().startsWith("org.codehaus.groovy.runtime.callsite"), "Stack trace has internal groovy callsite elements"); } } diff --git a/groovy/src/test/java/io/cucumber/groovy/GroovyWorldTest.java b/groovy/src/test/java/io/cucumber/groovy/GroovyWorldTest.java index b6af689..1953cc2 100644 --- a/groovy/src/test/java/io/cucumber/groovy/GroovyWorldTest.java +++ b/groovy/src/test/java/io/cucumber/groovy/GroovyWorldTest.java @@ -1,24 +1,25 @@ package io.cucumber.groovy; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class GroovyWorldTest { GroovyWorld world; - @Before + @BeforeEach public void setUp() { world = new GroovyWorld(); } - @Test(expected = RuntimeException.class) + @Test public void should_not_register_pure_java_object() { - world.registerWorld("JAVA"); + assertThrows(RuntimeException.class, () -> world.registerWorld("JAVA")); } @Test @@ -40,19 +41,19 @@ public void should_support_more_then_one_World() { assertEquals("no args", world.getProperty("methodArgs")); } - @Test(expected = RuntimeException.class) + @Test public void should_detect_double_property_definition() { world.registerWorld(new WorldWithPropertyAndMethod()); world.registerWorld(new AnotherCustomWorld()); - world.getProperty("aProperty"); + assertThrows(RuntimeException.class, () -> world.getProperty("aProperty")); } - @Test(expected = RuntimeException.class) + @Test public void should_detect_double_method_definition() { world.registerWorld(new WorldWithPropertyAndMethod()); world.registerWorld(new AnotherCustomWorld()); - world.invokeMethod("aMethod", new Integer[]{1, 2}); + assertThrows(RuntimeException.class, () -> world.invokeMethod("aMethod", new Integer[]{1, 2})); } } diff --git a/groovy/src/test/java/io/cucumber/groovy/HooksTest.java b/groovy/src/test/java/io/cucumber/groovy/HooksTest.java index 39a610a..7b40018 100644 --- a/groovy/src/test/java/io/cucumber/groovy/HooksTest.java +++ b/groovy/src/test/java/io/cucumber/groovy/HooksTest.java @@ -3,10 +3,10 @@ import io.cucumber.core.exception.CucumberException; import org.codehaus.groovy.runtime.MethodClosure; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class HooksTest { diff --git a/groovy/src/test/java/io/cucumber/groovy/ParallelTest.java b/groovy/src/test/java/io/cucumber/groovy/ParallelTest.java index 3608fdd..affd8ad 100644 --- a/groovy/src/test/java/io/cucumber/groovy/ParallelTest.java +++ b/groovy/src/test/java/io/cucumber/groovy/ParallelTest.java @@ -2,32 +2,29 @@ import groovy.lang.Closure; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import java.util.function.Supplier; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ParallelTest { @Mock Supplier classLoaderSupplier; @Mock - Closure closure; + Closure closure; @Test public void can_have_a_new_backend_on_a_different_thread() { new GroovyBackend(null, null, classLoaderSupplier); - Thread interactWithBackendThread = new Thread(new Runnable() { - @Override - public void run() { - try { - GroovyBackend.getInstance().registerWorld(closure); - } catch (NullPointerException e) { - // This is what we want as there should be no GroovyBackend on this thread - } + Thread interactWithBackendThread = new Thread(() -> { + try { + GroovyBackend.getInstance().registerWorld(closure); + } catch (NullPointerException e) { + // This is what we want as there should be no GroovyBackend on this thread } }); runAndWait(interactWithBackendThread); diff --git a/groovy/src/test/resources/junit-platform.properties b/groovy/src/test/resources/junit-platform.properties new file mode 100644 index 0000000..b48dd63 --- /dev/null +++ b/groovy/src/test/resources/junit-platform.properties @@ -0,0 +1 @@ +cucumber.publish.quiet=true diff --git a/pom.xml b/pom.xml index 389e4b2..e41f01b 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,6 @@ 26.1.0 4.0.11 5.9.2 - 5.3.1 io.cucumber.groovy @@ -46,40 +45,30 @@ - io.cucumber - cucumber-groovy - ${project.version} + org.junit + junit-bom + ${junit-jupiter.version} + pom + import io.cucumber - cucumber-core + cucumber-bom ${cucumber.version} - - - org.apache.groovy - groovy-all - ${groovy.version} pom - provided + import - io.cucumber - cucumber-junit - ${cucumber.version} - test - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test + cucumber-groovy + ${project.version} - org.mockito - mockito-core - ${mockito.version} - test + org.apache.groovy + groovy-bom + ${groovy.version} + pom + import From 5dfc2ecac69d456c6b76ca54954a032ebcbfc27c Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 20:33:22 +0800 Subject: [PATCH 16/18] put `groovy-cli-test` back in. Remove `--strict` flag since it is no longer supported, because it defaults to strict-mode. (See: https://github.com/cucumber/cucumber-jvm/commit/5fbae84e74de246b2c31336f92f62167680d072f) --- groovy/pom.xml | 54 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/groovy/pom.xml b/groovy/pom.xml index fd92805..f1914e1 100644 --- a/groovy/pom.xml +++ b/groovy/pom.xml @@ -173,26 +173,54 @@ - - CLI-test + copy-full-jar + package + + + + + + + run + + + + groovy-cli-test integration-test run - - - - - - + + + + + + + + + + + + + + + + + From bd445f721795118eac12b2adb7ae1b615451e4d6 Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 20:39:58 +0800 Subject: [PATCH 17/18] since we revert back to previous groovy-cli-test, we do not need the junit console launcher anymore --- groovy/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/groovy/pom.xml b/groovy/pom.xml index f1914e1..bad8f64 100644 --- a/groovy/pom.xml +++ b/groovy/pom.xml @@ -75,11 +75,6 @@ cucumber-junit-platform-engine test - - org.junit.platform - junit-platform-console - test - org.mockito mockito-core From 14f710ef6d75493a0884ba26e1e7f4fa6b55d22c Mon Sep 17 00:00:00 2001 From: lsiu Date: Sun, 23 Apr 2023 20:44:14 +0800 Subject: [PATCH 18/18] add change info to CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a9910a..f613f20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ See also the [CHANGELOG](https://github.com/cucumber/cucumber-jvm/blob/main/CHAN ### Added ### Changed +* Upgrade to latest groovy version 4.0.11 and cucumber-jvm 7.11.2 +* Upgrading to Surefire v3 so we can use JUnit 5. +* Using Bills of Material to keep all the dependencies aligned (and remove all the explicit version numbers everywhere) +* Replacing JUnit 4 with JUnit 5. ### Deprecated