-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Issues when migrating to Cucumber 3.x.x/4.x.x from cucumber 2.x.x #1478
Comments
Cucumber uses semantic versioning, which means that a major version increment has backwards incompatible changes. You should expect to have to make changes when upgrading a major version. In v3 the type conversion happened in Cucumber, based on the type information from the method's parameters. In v4 the type conversion happens in the Cucumber-Expressions library, which doesn't have access to the method's parameters. It is possible to implicitly refer to parameter types from stepdefs using regular expressions by using capture group patterns identical to a parameter type. If you change We could make a change to Cucumber-Expressions so that WDYT @mpkorstanje? |
In principle I could see that work for regular expressions. The type hint But as of yet I don't quite see how the type hint and type indicated by the cucumber expression should interact. Or how this system can give clear feedback on what it does, tried to do and why it failed when it does. The hint should ofc. be optional to handle weakly typed JVM Lang's. Executing the transform to the hinted type does require an object mapper. And here we should avoid all the mistakes by the XStream implementation. So:
If you want to jak shave this doing the bare bones mapper and type hint for regular expressions aswell as the type checking for cucumber expressions should be a good start. I think the other stuff requires breaking changes anyway. |
Comes to mind that cucumber expressions currently transforms a list of capture groups to objects. For most cases this is a single string so for all the basic types cucumber expressions could also use the bare bones object mapper with String --> Object, and for multiple String[] -> Object. Assuming there is no expression defined ofc. This would avoid allot of annoying inconsistencies and would let us extract the locale from the parameter type registery. |
And with that in mind an anonymous cucumber expression parameter |
Thank you very much for your explanations ! Please let me know in this thread if there is any chance of supporting this backward compatibility in one of the next versions. As I said, there are some projects outthere which are having troubles upgrading a large number of tests. Thanks ! |
Related: cucumber/docs#142 |
Introduces the anonymous parameter to cucumber expressions. This is a breaking change because we're installing a new expression in the parameter type registry. \#\# Details ## Installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` For Javascript and Ruby this will merely returns the captured text as a string. However for strongly typed languages like Java and Go this make this allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example in Java the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #493 \#\# Motivation and Context \#\# To make it easier to upgrade from Cucumber-JVM v3 to v4. See cucumber/cucumber-jvm#1478 for details.
Introduces the anonymous parameter to cucumber expressions. This is a breaking change because we're installing a new expression in the parameter type registry. \#\# Details ## Installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` For Javascript and Ruby this will merely returns the captured text as a string. However for strongly typed languages like Java and Go this make this allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example in Java the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #493 \#\# Motivation and Context \#\# To make it easier to upgrade from Cucumber-JVM v3 to v4. See cucumber/cucumber-jvm#1478 for details.
Introduces the anonymous parameter to cucumber expressions. This is a breaking change because we're installing a new expression in the parameter type registry. \#\# Details ## Installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` For Javascript and Ruby this will merely returns the captured text as a string. However for strongly typed languages like Java and Go this make this allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example in Java the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #493 \#\# Motivation and Context \#\# To make it easier to upgrade from Cucumber-JVM v3 to v4. See cucumber/cucumber-jvm#1478 for details.
Introduces the anonymous parameter to cucumber expressions. This is a breaking change because we're installing a new expression in the parameter type registry. \#\# Details ## Installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` For Javascript and Ruby this will merely returns the captured text as a string. However for strongly typed languages like Java and Go this make this allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example in Java the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #493 \#\# Motivation and Context \#\# To make it easier to upgrade from Cucumber-JVM v3 to v4. See cucumber/cucumber-jvm#1478 for details.
Introduces the anonymous parameter to cucumber expressions. This is a breaking change because we're installing a new expression in the parameter type registry. \#\# Details ## Installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` For Javascript and Ruby this will merely returns the captured text as a string. However for strongly typed languages like Java and Go this make this allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example in Java the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #493 \#\# Motivation and Context \#\# To make it easier to upgrade from Cucumber-JVM v3 to v4. See cucumber/cucumber-jvm#1478 for details.
Introduces the anonymous parameter to cucumber expressions. This is a breaking change because we're installing a new expression in the parameter type registry. \#\# Details ## Installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` For Javascript and Ruby this will merely returns the captured text as a string. However for strongly typed languages like Java and Go this make this allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example in Java the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #493 \#\# Motivation and Context \#\# To make it easier to upgrade from Cucumber-JVM v3 to v4. See cucumber/cucumber-jvm#1478 for details.
Introduces the anonymous parameter to cucumber expressions. This is a breaking change because we're installing a new expression in the parameter type registry. \#\# Details ## Installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` For Javascript and Ruby this will merely returns the captured text as a string. However for strongly typed languages like Java and Go this make this allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example in Java the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #493 \#\# Motivation and Context \#\# To make it easier to upgrade from Cucumber-JVM v3 to v4. See cucumber/cucumber-jvm#1478 for details.
Cucubumber expressions installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` This allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #1478
Cucubumber expressions installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` This allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #1478
Cucubumber expressions installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` This allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #1478
Cucubumber expressions installs the anonymous parameter type into the registry: ```java ParameterType( name: "" regexps: [\.*\] transformer: s -> s useForSnippets: false preferForRegexMatch: true ) ``` This allows the step definition to hint the type to which the captured text should be converted. When used in conjunction with an object mapper this makes it easier to quickly define step definitions without the need to define parameter types for each type. For example the following will work without the need to configure additional parameter types. ```java Given("^there is some date (.*)$", (Date a) -> { }) Given("there is some date {}", (Date a) -> { }) Given("there is some transaction {} {}", (BigDecimal a, Currency b) -> { }) Given("there is some type {}", (TypeEnum a) -> { }) ``` To make the dynamic transform possible type hints are passed to the cucumber expression when matching a step. Using these hints the `s -> s` transform is replaced with `s -> defaultTransform.transform(s, typeHint)`. A simple implementation of the `defaultTransform` is provided that supports a selection of primitives but should generally speaking be replaced with a proper object mapper. Fixes: #1478
4.2.0 has been released. Release notes can be found here: |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
In cucumber-jvm 2.x.x, I had a step defined like this:
When running the tests with Cucumber 3.x.x , I got this error
Expected Behavior
Current Behavior
Possible Solution
Context & Motivation
The problem is that upgrading to newer cucumber version breaks the existing tests. For some projects, updating a large number of tests can be a real problem.
The text was updated successfully, but these errors were encountered: