The Aliases surely address my requirements, thanks for the input. I think Alias need more documentation love, could have saved me couple of days :)
BTW, the other change to distinguish between Given/When/Then annotations, how will it impact Aliases? - Hitesh [http://hitesh.in/] 2009/10/29 Mauro Talevi <[email protected]>: > Hitesh Sarda wrote: >> >> The current use case is allow a bit more relaxed / flexible syntax. >> >> So I want to map all of these step definitions to a single step. >> >> When the item price is 25 >> When the item price = 25 >> When the item price equals 25$ >> When the item price is equal to 25 >> >> So I could write a When annotation something like: >> @When("the item price.+[0-9\.]+$*") >> >> Haven't tested the regex above, but hope you get the idea. >> >> Will look at the PrefixCapturingPatternBuilder and try to find a >> solution. Any pointers are welcome. >> > > One of possible drawbacks of this approach is it's potential lack of > transparency. > > JBehave addresses this use cases with aliases. For example > > @When("the item price is $price") > @Alias("the item prices = $price") // single alias > public void theItemPriceIs(double price) { > // ... > } > > or > > @When("the item price is $price") > @Aliases(values={"the item price = $price" > "the item price equals $price}) // multiple aliases > public void theItemPriceIs(double price) { > // ... > } > > Makes readability easier, unless you eat regex for breakfast :-) > > Other approaches are also possible, of course, but they may be more prone to > problems as you need to ensure that what comes out of the pattern builder is > correctly understood by the CandidateStep. > > > Cheers > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
