-
Notifications
You must be signed in to change notification settings - Fork 22
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
Support for argument transforms #9
Comments
Example:
|
I've done parameter type conversion in the invocation code here (http://github.com/richardlawrence/Cuke4Nuke/blob/step_definition_parameters/Cuke4Nuke/Core/StepDefinitionRepository.cs) such that if you register a custom TypeConverter than can convert from string you can then use your type as a parameter. As far as I can tell, this accomplishes the same thing as argument transforms without changing the regexp format, which I like better. |
Registering custom type converters is messy, though. For example, to register a custom type converter, you have to decorate the class that you want to convert. This does two things, (1) it forces the user to modify the class that is being executed/passed and (2) it moves the logic for the conversion into a different class. I prefer modifying the regular expression for this case. Especially, since such a modification has been accepted within cucumber proper. That said, grabbing the type formatter is still a great idea. It covers the types that have built-in type converters like Font and Point and others. |
May I throw in my two cents? Fitnesse looks for a static Parse method on the object and uses that to convert the text into the object if it exists. This works for all of the value types and might be a nice easy compromise between the complexity of TypeConverter and modifying the regular expressions (which could be a breaking change). I'd be willing to give this a shot, if anyone wanted |
@x97mdr - I wouldn't mind if it tried the TypeConverter first, which works well for many of the basic types, and then fell back on a static Parse(string) method if one exists. Feel free to give it a shot and send me a pull request when it's ready. Thanks. |
Add support for the use of argument transforms in the Given/When/Then regular expressions.
The text was updated successfully, but these errors were encountered: