Comments (5)
Example:
[Transform("^user \w+$")]
public static User TransformUser(string userName) {
return new User(userName);
}
[Given("^(user \w+) is assigned (user \w+)$"]
public static void UserIsAssignedAnotherUser(User user, User userToAssign) {
user.Assign(userToAssign);
}
from cuke4nuke.
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.
from cuke4nuke.
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.
from cuke4nuke.
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
from cuke4nuke.
@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.
from cuke4nuke.
Related Issues (20)
- Cuke4Nuke doesn't work with Watin HOT 3
- Support for pending step definitions
- Cuke4Nuke wrapper eats Cucumber console colors
- Support for hooks associated with tags
- Handshake in wire protocol
- More complete Table class
- cuke4nuke install issue HOT 5
- Background HOT 2
- Pass Scenario object to hooks
- Capture group positions are incorrect for UTF-8 steps
- JSON is not properly escaped for snippets (and possibly other JSON messages) HOT 2
- Write console output as Cucumber runs each scenario instead of all at end
- Visual Studio Debugging of Step Definitions
- Improve build/release automation HOT 2
- Support for config files
- Use matching culture for internationalized step definitions
- Cuk4Nuke fails on creating object HOT 2
- How to use Cuke4Nuke on .Net Framework 4.0 HOT 2
- .NET 4 compatibility HOT 1
- What License applies to this project
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cuke4nuke.