Skip to content

Commit ada4138

Browse files
lsiumpkorstanje
andauthored
Update to latest groovy and cucumber jvm (#47)
Co-authored-by: lsiu <[email protected]> Co-authored-by: M.P. Korstanje <[email protected]>
1 parent cbedf32 commit ada4138

21 files changed

+182
-202
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ See also the [CHANGELOG](https://github.com/cucumber/cucumber-jvm/blob/main/CHAN
1212
### Added
1313

1414
### Changed
15+
* Upgrade to latest groovy version 4.0.11 and cucumber-jvm 7.11.2
16+
* Upgrading to Surefire v3 so we can use JUnit 5.
17+
* Using Bills of Material to keep all the dependencies aligned (and remove all the explicit version numbers everywhere)
18+
* Replacing JUnit 4 with JUnit 5.
1519

1620
### Deprecated
1721

examples/pom.xml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,53 @@
44
<parent>
55
<groupId>io.cucumber</groupId>
66
<artifactId>cucumber-jvm-groovy</artifactId>
7-
<version>6.10.5-SNAPSHOT</version>
7+
<version>7.0.0-SNAPSHOT</version>
88
</parent>
99

1010
<artifactId>groovy-examples</artifactId>
1111
<packaging>jar</packaging>
1212
<name>Cucumber Groovy Examples</name>
1313

14-
<properties>
15-
<gmaven.runtime>1.8</gmaven.runtime>
16-
<junit-jupiter.version>5.6.0</junit-jupiter.version>
17-
</properties>
18-
1914
<dependencies>
2015
<dependency>
2116
<groupId>io.cucumber</groupId>
2217
<artifactId>cucumber-groovy</artifactId>
2318
<scope>test</scope>
2419
</dependency>
2520
<dependency>
26-
<groupId>io.cucumber</groupId>
27-
<artifactId>cucumber-junit</artifactId>
21+
<groupId>org.junit.platform</groupId>
22+
<artifactId>junit-platform-suite</artifactId>
2823
<scope>test</scope>
2924
</dependency>
3025
<dependency>
3126
<groupId>org.junit.jupiter</groupId>
3227
<artifactId>junit-jupiter</artifactId>
33-
<version>${junit-jupiter.version}</version>
3428
<scope>test</scope>
3529
</dependency>
3630
<dependency>
37-
<groupId>org.codehaus.groovy</groupId>
38-
<artifactId>groovy-all</artifactId>
31+
<groupId>io.cucumber</groupId>
32+
<artifactId>cucumber-junit-platform-engine</artifactId>
33+
<scope>test</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.apache.groovy</groupId>
37+
<artifactId>groovy</artifactId>
3938
<scope>provided</scope>
4039
</dependency>
4140
</dependencies>
4241

4342
<build>
4443
<plugins>
4544
<plugin>
46-
<groupId>org.codehaus.gmaven</groupId>
47-
<artifactId>gmaven-plugin</artifactId>
45+
<groupId>org.codehaus.gmavenplus</groupId>
46+
<artifactId>gmavenplus-plugin</artifactId>
4847
<executions>
4948
<execution>
5049
<goals>
5150
<goal>generateStubs</goal>
5251
<goal>compile</goal>
5352
<goal>generateTestStubs</goal>
54-
<goal>testCompile</goal>
53+
<goal>compileTests</goal>
5554
</goals>
5655
</execution>
5756
</executions>

examples/src/test/groovy/calc/CalculatorSteps.groovy

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ Given(~/^I have entered (\d+) into .* calculator$/) { int number ->
5151
calc.push number
5252
}
5353

54-
// Remember to still include "->" if there are no parameters.
55-
Given(~/\d+ into the/) {->
56-
throw new RuntimeException("should never get here since we're running with --guess")
57-
}
58-
5954
// This step calls a Calculator function specified in the step
6055
// and saves the result in the current world object.
6156
When(~/^I press (\w+)$/) { String opname ->
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package calc;
22

33

4-
import io.cucumber.junit.Cucumber;
5-
import io.cucumber.junit.CucumberOptions;
6-
import org.junit.runner.RunWith;
4+
import org.junit.platform.suite.api.ConfigurationParameter;
5+
import org.junit.platform.suite.api.IncludeEngines;
6+
import org.junit.platform.suite.api.SelectClasspathResource;
7+
import org.junit.platform.suite.api.Suite;
78

8-
@RunWith(Cucumber.class)
9-
@CucumberOptions(glue = {"calc"} )
9+
import static io.cucumber.core.options.Constants.GLUE_PROPERTY_NAME;
10+
11+
@Suite
12+
@IncludeEngines("cucumber")
13+
@SelectClasspathResource("calc")
14+
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "calc")
1015
public class RunCukesTest {
1116
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cucumber.publish.quiet=true

groovy/pom.xml

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,87 @@
44
<parent>
55
<groupId>io.cucumber</groupId>
66
<artifactId>cucumber-jvm-groovy</artifactId>
7-
<version>6.10.5-SNAPSHOT</version>
7+
<version>7.0.0-SNAPSHOT</version>
88
</parent>
99

1010
<artifactId>cucumber-groovy</artifactId>
1111
<packaging>jar</packaging>
1212
<name>Cucumber Groovy</name>
1313

1414
<properties>
15-
<gmaven.runtime>1.8</gmaven.runtime>
1615
<jackson.version>2.14.2</jackson.version>
17-
<junit-jupiter.version>5.9.2</junit-jupiter.version>
16+
<mockito.version>5.3.1</mockito.version>
1817
</properties>
1918

19+
<dependencyManagement>
20+
<dependencies>
21+
<dependency>
22+
<groupId>com.fasterxml.jackson</groupId>
23+
<artifactId>jackson-bom</artifactId>
24+
<version>${jackson.version}</version>
25+
<scope>import</scope>
26+
<type>pom</type>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.mockito</groupId>
30+
<artifactId>mockito-bom</artifactId>
31+
<version>${mockito.version}</version>
32+
<scope>import</scope>
33+
<type>pom</type>
34+
</dependency>
35+
</dependencies>
36+
</dependencyManagement>
37+
2038
<dependencies>
2139
<dependency>
2240
<groupId>io.cucumber</groupId>
2341
<artifactId>cucumber-core</artifactId>
2442
</dependency>
2543
<dependency>
26-
<groupId>org.codehaus.groovy</groupId>
27-
<artifactId>groovy-all</artifactId>
44+
<groupId>org.apache.groovy</groupId>
45+
<artifactId>groovy</artifactId>
2846
<scope>provided</scope>
2947
</dependency>
48+
<dependency>
49+
<groupId>org.apache.groovy</groupId>
50+
<artifactId>groovy-test</artifactId>
51+
<scope>test</scope>
52+
</dependency>
3053
<dependency>
3154
<groupId>com.fasterxml.jackson.datatype</groupId>
3255
<artifactId>jackson-datatype-jsr310</artifactId>
33-
<version>${jackson.version}</version>
3456
<scope>test</scope>
3557
</dependency>
3658
<dependency>
3759
<groupId>com.fasterxml.jackson.core</groupId>
3860
<artifactId>jackson-databind</artifactId>
39-
<version>${jackson.version}</version>
4061
<scope>test</scope>
4162
</dependency>
4263
<dependency>
43-
<groupId>io.cucumber</groupId>
44-
<artifactId>cucumber-junit</artifactId>
64+
<groupId>org.junit.jupiter</groupId>
65+
<artifactId>junit-jupiter</artifactId>
4566
<scope>test</scope>
4667
</dependency>
4768
<dependency>
48-
<groupId>org.junit.jupiter</groupId>
49-
<artifactId>junit-jupiter</artifactId>
50-
<version>${junit-jupiter.version}</version>
69+
<groupId>org.junit.platform</groupId>
70+
<artifactId>junit-platform-suite</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>io.cucumber</groupId>
75+
<artifactId>cucumber-junit-platform-engine</artifactId>
5176
<scope>test</scope>
5277
</dependency>
5378
<dependency>
5479
<groupId>org.mockito</groupId>
5580
<artifactId>mockito-core</artifactId>
5681
<scope>test</scope>
5782
</dependency>
83+
<dependency>
84+
<groupId>org.mockito</groupId>
85+
<artifactId>mockito-junit-jupiter</artifactId>
86+
<scope>test</scope>
87+
</dependency>
5888
<dependency>
5989
<groupId>com.google.auto.service</groupId>
6090
<artifactId>auto-service</artifactId>
@@ -67,7 +97,6 @@
6797
<plugin>
6898
<groupId>org.codehaus.gmavenplus</groupId>
6999
<artifactId>gmavenplus-plugin</artifactId>
70-
<version>2.1.0</version>
71100
<executions>
72101
<execution>
73102
<goals>
@@ -167,14 +196,12 @@
167196
<echo message="Running groovy tests via the CLI..." />
168197
<java classname="groovy.ui.GroovyMain" fork="true" failonerror="true" newenvironment="true" maxmemory="512m" classpathref="maven.test.classpath">
169198
<classpath>
170-
<pathelement location="${maven.dependency.org.codehaus.groovy.groovy-all.jar.path}" />
199+
<pathelement location="${maven.dependency.org.apache.groovy.groovy-ant.jar.path}" />
171200
<pathelement location="${maven.dependency.junit.junit.jar.path}" />
172201
<pathelement location="${basedir}/bin/cucumber-groovy-shaded.jar" />
173202
<pathelement location="target/test-classes" />
174203
</classpath>
175204
<arg value="bin/cucumber-jvm.groovy" />
176-
<arg value="--strict" />
177-
178205
<!--
179206
target/test-classes/cucumber/runtime/groovy contains:
180207

groovy/src/main/groovy/I18n.groovy.gsp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ import java.util.regex.Pattern;
88
public class ${normalized_language} {
99
<% i18n.stepKeywords.findAll { !it.contains('*') && !it.matches("^\\d.*") }.unique().each { kw -> %>
1010

11-
public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)}(String[] expressions, Closure body) throws Throwable {
11+
public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!\u2019]", ""), java.text.Normalizer.Form.NFC)}(String[] expressions, Closure body) throws Throwable {
1212
Arrays.stream(expressions).forEach(expression->
1313
GroovyBackend.getInstance().addStepDefinition(expression, body)
1414
);
1515
}
1616

17-
public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)}(Pattern[] regexps, Closure body) throws Throwable {
17+
public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!\u2019]", ""), java.text.Normalizer.Form.NFC)}(Pattern[] regexps, Closure body) throws Throwable {
1818
Arrays.stream(regexps).forEach(regexp->
19-
GroovyBackend.getInstance().addStepDefinition(regexp.toString(), body)
19+
GroovyBackend.getInstance().addStepDefinition("/" + regexp.toString() + "/", body)
2020
);
2121
}
2222

23-
public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)}(String expression, Closure body) throws Throwable {
23+
public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!\u2019]", ""), java.text.Normalizer.Form.NFC)}(String expression, Closure body) throws Throwable {
2424
GroovyBackend.getInstance().addStepDefinition(expression, body);
2525
}
2626

27-
public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)}(Pattern regexp, Closure body) throws Throwable {
28-
GroovyBackend.getInstance().addStepDefinition(regexp.toString(), body);
27+
public static void ${java.text.Normalizer.normalize(kw.replaceAll("[\\s',!\u2019]", ""), java.text.Normalizer.Form.NFC)}(Pattern regexp, Closure body) throws Throwable {
28+
GroovyBackend.getInstance().addStepDefinition("/" + regexp.toString() + "/", body);
2929
}
3030
<% } %>
3131
}

groovy/src/main/groovy/generate-keywords.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def unsupported = ["EM"] // The generated files for Emoij do not compile.
88
def dialectProvider = new GherkinDialectProvider()
99

1010
dialectProvider.getLanguages().each { language ->
11-
def dialect = dialectProvider.getDialect(language, null)
11+
def dialect = dialectProvider.getDialect(language).orElseThrow()
1212
def normalized_language = dialect.language.replaceAll("[\\s-]", "_").toUpperCase()
1313
if (!unsupported.contains(normalized_language)) {
1414
def binding = ["i18n":dialect, "normalized_language":normalized_language]

groovy/src/test/groovy/io/cucumber/groovy/TypeRegistryConfiguration.groovy

Lines changed: 0 additions & 60 deletions
This file was deleted.

groovy/src/test/groovy/io/cucumber/groovy/compiled_stepdefs.groovy

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.cucumber.groovy
33
import io.cucumber.groovy.EN
44
import io.cucumber.datatable.DataTable
55

6-
import static groovy.util.GroovyTestCase.assertEquals
6+
import static groovy.test.GroovyTestCase.assertEquals
77

88
this.metaClass.mixin(EN)
99
this.metaClass.mixin(Hooks)
@@ -19,11 +19,24 @@ Given(~'^I have (\\d+) apples in my belly') { int apples ->
1919
Given(~'^a big basket with cukes') { ->
2020
}
2121

22+
@DataTableType
23+
Thing dataTableTypeThing(Map<String, String> tableEntry) {
24+
Thing thing = new Thing()
25+
thing.year = Integer.valueOf(tableEntry.get("year"))
26+
thing.name = tableEntry.get("name")
27+
thing
28+
}
29+
2230
Given(~'^the following table:$') { DataTable table ->
2331
things = table.asList(Thing)
2432
assertEquals("Cucumber-JVM", things[1].name)
2533
}
2634

35+
@ParameterType(name="list", value="(.+\\s*,\\s*.+){1,}")
36+
List parameterTypeList(String[] s) {
37+
Arrays.asList(s[0].split(","))*.trim()
38+
}
39+
2740
Given('this should be converted to a list:{list}') { List list ->
2841
assertEquals(3, list.size())
2942
assertEquals("Cucumber-JVM", list.get(0))

0 commit comments

Comments
 (0)