Skip to content

Update to latest groovy and cucumber jvm #47

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
abc717e
Update dependency org.apache.maven.plugins:maven-surefire-plugin to v3
renovate[bot] Apr 22, 2023
2e98df3
bump version to 7.0.0-SNAPSHOT to align with cucumber 7.x versions
lsiu Apr 23, 2023
4153a22
upgrade to latest stable groovy version 4.0.11
lsiu Apr 23, 2023
8707db9
package migrated for `GroovyTestCase` to `groovy.test`
lsiu Apr 23, 2023
32ccef5
fix signature change to `io.cucumber.gherkin.GherkinDialectProvider.g…
lsiu Apr 23, 2023
e90d7a8
EN_TX introduced a special character ’ or '\u2019', which we need to …
lsiu Apr 23, 2023
c517dad
I think a test to test "~/^I press (\w+)$/" overloaded by "~/^I have …
lsiu Apr 23, 2023
78f1c24
renovate bot left out a place also update the `junit-jupiter.version`?
lsiu Apr 23, 2023
4179475
wrapping regexp text with "/", will allow `ExpressionFactory` from `c…
lsiu Apr 23, 2023
23b8eef
`TypeRegistryConfigurer` is no longer supported. Use @DataTableType a…
lsiu Apr 23, 2023
2df2f1a
use `org.junit.platform.console.ConsoleLauncher` for CLI test instead…
lsiu Apr 23, 2023
a9e4df4
add running test via `junit-platform-suite`. See: https://github.com/…
lsiu Apr 23, 2023
c48959e
update `examples` test runner to use latest `cucumber-junit-platform-…
lsiu Apr 23, 2023
16140ef
move `example` to also use gmavenplus-plugin plugin
lsiu Apr 23, 2023
27901be
Merge remote-tracking branch 'origin/renovate/org.apache.maven.plugin…
mpkorstanje Apr 23, 2023
37df5c9
Housekeeping
mpkorstanje Apr 23, 2023
5dfc2ec
put `groovy-cli-test` back in. Remove `--strict` flag since it is no …
lsiu Apr 23, 2023
bd445f7
since we revert back to previous groovy-cli-test, we do not need the …
lsiu Apr 23, 2023
14f710e
add change info to CHANGELOG.md
lsiu Apr 23, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 13 additions & 14 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,53 @@
<parent>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm-groovy</artifactId>
<version>6.10.5-SNAPSHOT</version>
<version>7.0.0-SNAPSHOT</version>
</parent>

<artifactId>groovy-examples</artifactId>
<packaging>jar</packaging>
<name>Cucumber Groovy Examples</name>

<properties>
<gmaven.runtime>1.8</gmaven.runtime>
<junit-jupiter.version>5.6.0</junit-jupiter.version>
</properties>

<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-groovy</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
Expand Down
5 changes: 0 additions & 5 deletions examples/src/test/groovy/calc/CalculatorSteps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
15 changes: 10 additions & 5 deletions examples/src/test/java/calc/RunCukesTest.java
Original file line number Diff line number Diff line change
@@ -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 {
}
1 change: 1 addition & 0 deletions examples/src/test/resources/junit-platform.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cucumber.publish.quiet=true
59 changes: 43 additions & 16 deletions groovy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,87 @@
<parent>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm-groovy</artifactId>
<version>6.10.5-SNAPSHOT</version>
<version>7.0.0-SNAPSHOT</version>
</parent>

<artifactId>cucumber-groovy</artifactId>
<packaging>jar</packaging>
<name>Cucumber Groovy</name>

<properties>
<gmaven.runtime>1.8</gmaven.runtime>
<jackson.version>2.14.2</jackson.version>
<junit-jupiter.version>5.9.2</junit-jupiter.version>
<mockito.version>5.3.1</mockito.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${jackson.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-bom</artifactId>
<version>${mockito.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
Expand All @@ -67,7 +97,6 @@
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -167,14 +196,12 @@
<echo message="Running groovy tests via the CLI..." />
<java classname="groovy.ui.GroovyMain" fork="true" failonerror="true" newenvironment="true" maxmemory="512m" classpathref="maven.test.classpath">
<classpath>
<pathelement location="${maven.dependency.org.codehaus.groovy.groovy-all.jar.path}" />
<pathelement location="${maven.dependency.org.apache.groovy.groovy-ant.jar.path}" />
<pathelement location="${maven.dependency.junit.junit.jar.path}" />
<pathelement location="${basedir}/bin/cucumber-groovy-shaded.jar" />
<pathelement location="target/test-classes" />
</classpath>
<arg value="bin/cucumber-jvm.groovy" />
<arg value="--strict" />

<!--
target/test-classes/cucumber/runtime/groovy contains:

Expand Down
12 changes: 6 additions & 6 deletions groovy/src/main/groovy/I18n.groovy.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ 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)
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 {
GroovyBackend.getInstance().addStepDefinition(regexp.toString(), body);
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);
}
<% } %>
}
2 changes: 1 addition & 1 deletion groovy/src/main/groovy/generate-keywords.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -19,11 +19,24 @@ Given(~'^I have (\\d+) apples in my belly') { int apples ->
Given(~'^a big basket with cukes') { ->
}

@DataTableType
Thing dataTableTypeThing(Map<String, String> 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading