Skip to content

Redefine default processing for ParameterType and DocStringType #1909

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

Closed
john-caleb-phillips opened this issue Mar 3, 2020 · 4 comments
Closed
Labels
⚡ enhancement Request for new functionality

Comments

@john-caleb-phillips
Copy link

In issue #1884 asked if it would be possible to allow redefinition of the default DataTableType of String -> String, so that replaceWithEmptyString could be defined.

Would it be possible to also allow redefinition of the default ParameterType and DocString types for String? I have a use case that is outside the bounds of what Cucumber is "supposed" to do, and to make it work I've had to do some highly questionable things with the Reflection API to unregister the default converters so I can define my own.

For reference, the odd use case is that my boss wanted to be able to pre-parse the inputs, so that if the parameter contains a specific pattern it can be converted to a value from a properties file. The correct approach would have been to define a new object like "ConvertedString", and used that in the step definitions, but my boss rejected that as too complex.

@john-caleb-phillips john-caleb-phillips added the ⚡ enhancement Request for new functionality label Mar 3, 2020
@john-caleb-phillips john-caleb-phillips changed the title Unable to configure a DataTableType for a List<List<String>> type #1884 Redefine default processing for ParameterType and DocStringType Mar 3, 2020
@mpkorstanje
Copy link
Contributor

Have you considered using a cucumber expression and/or custom docstring type?

@ParameterType("some regex pattern")
public String interpolatedString(String string){
  return interpolate(string);
}

@Given("some {interpolatedString}")
public void some_interpolated_string(String interpolated){

}
Scenario: Example
  Given some "{interpolated string}"
@DocStringType
public String interpolated(String docString){
  return interpolate(docString);
}
Scenario: Example
  Given some doc string
     """interpolated
      {interpolated string}
     """

@john-caleb-phillips
Copy link
Author

Yes, this was suggested as well, but also rejected. The boss wants the conversion to be invisible to the people who are writing the steps and features in our projects.

@mpkorstanje
Copy link
Contributor

Unfortunately I don't see a good reason to support this. Cucumber is a tool to support BDD and assumes that all people involved are communicating and collaborating. It would be rather weird to hide behavior like this.

@john-caleb-phillips
Copy link
Author

Fair enough. I just figured I'd ask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants