Hi Gaspar,
Apologies if you've had this discussion countless times before, but I just started using SpecFlow yesterday and may have missed some related posts.
My first thought on writing SpecFlow step definitions was "Why the duplication between method name and attribute regex? Can't this extra effort be factored out somehow?" So I went digging and found your work on step definitions without a supplied regex. It's pretty much what I'm looking for, and my team would like to follow this approach for writing our acceptance tests.
I have a few comments.
- Why not get rid of Given/When/Then attributes entirely? You could continue to mark your class with the Binding attribute, but then automatically assume any method named Given* is a given, When* is a when and Then* is a then - if you see what I mean. In other words, move to a convention-based model rather than an attribute-based model, which is becoming more common in .NET projects (see, for example, MEF).
- My prefered naming practice would be 'When_person_does_something (string person)' rather than 'When_WHO_does_something (string who)'. It wouldn't affect your implementation but the method name becomes more readable/understandable - so may be important when you come to document this feature.
- Is the capitalization in the method names important? How about matching on the parameter name itself so that any case can be used?
Thanks
Daniel
On Tuesday, 15 May 2012 15:04:53 UTC+1, Gáspár Nagy wrote:
Hi Gaspar,
Apologies if you've had this discussion countless times before, but I just started using SpecFlow yesterday and may have missed some related posts.
My first thought on writing SpecFlow step definitions was "Why the duplication between method name and attribute regex? Can't this extra effort be factored out somehow?" So I went digging and found your work on step definitions without a supplied regex. It's pretty much what I'm looking for, and my team would like to follow this approach for writing our acceptance tests.
I have a few comments.
- Why not get rid of Given/When/Then attributes entirely? You could continue to mark your class with the Binding attribute, but then automatically assume any method named Given* is a given, When* is a when and Then* is a then - if you see what I mean. In other words, move to a convention-based model rather than an attribute-based model, which is becoming more common in .NET projects (see, for example, MEF).
- My prefered naming practice would be 'When_person_does_something (string person)' rather than 'When_WHO_does_something (string who)'. It wouldn't affect your implementation but the method name becomes more readable/understandable - so may be important when you come to document this feature.
- Is the capitalization in the method names important? How about matching on the parameter name itself so that any case can be used?
Thanks
Daniel
On Tuesday, 15 May 2012 15:04:53 UTC+1, Gáspár Nagy wrote:
I have a few comments.