[ http://jira.codehaus.org/browse/JBEHAVE-232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=225997#action_225997 ]
Jonathan Ross commented on JBEHAVE-232: --------------------------------------- Hi Paul. Sorry if my examples weren't clear enough. I was not familiar with the Paranamer functionality when I entered this issue, indeed it seems that this addresses my first point quite nicely. Regarding my second point, what I would like to be able to do, is to use a single step multiple times in an example table. Take the following scenario (using the steps from the trader scenarios from org.jbehave.examples): {code} Scenario: Example table trying to reuse the step with another column Given a stock of <first symbol> and a <first threshold> And a stock of <second symbol> and a <second threshold> Examples: |first symbol|first threshold|second symbol|second threshold| |B |10 |B |20 | {code} Running this scenario using a recent trunk revision of jBehave (revision 1661) leads to {code} Given a stock of <first symbol> and a <first threshold> (PENDING) And a stock of <second symbol> and a <second threshold> (PENDING) {code} I think it should be possible to name the parameter anything in the scenario file, regardless of the exact parameter names declared in the step annotation. Currently the only way I can come up with that would work is to explicitly chain steps with all the parameter names used in the scenario, like this: {noformat} @Given("a stock of symbol %symbol and a threshold of %threshold") @Alias("a stock of <symbol> and a <threshold>") // alias used with examples table public void aStock(@Named("symbol") String symbol, @Named("threshold") double threshold) { stock = service.newStock(symbol, threshold); } @Given("a stock of <first symbol> and a <first threshold>") public void aFirstStock(@Named("first symbol") String symbol, @Named("first threshold") double threshold) { aStock(symbol, threshold); } @Given("a stock of <second symbol> and a <second threshold>") public void aSedondStock(@Named("second symbol") String symbol, @Named("second threshold") double threshold) { aStock(symbol, threshold); } {noformat} To be honest, I think that it is strange to have to introduce separate aliases for tables at all. I would like to be able to run the example scenario above with one single {...@given}} annotation: {noformat} @Given("a stock of $symbol and a $threshold") // alias used with examples table public void aStock(String symbol, double threshold) { stock = service.newStock(symbol, threshold); } {noformat} > Replace @Named variable annotation by pattern matching of variable names used > in step annotation > ------------------------------------------------------------------------------------------------ > > Key: JBEHAVE-232 > URL: http://jira.codehaus.org/browse/JBEHAVE-232 > Project: JBehave > Issue Type: Improvement > Components: Core > Affects Versions: 2.3.2 > Reporter: Jonathan Ross > > If the {...@named}} annotation was deprecated, and the {{$variable}} patterns > were matched to the steps argument list instead, jBehave would be much more > usable. > The {...@named}} parameter annotations are in essence redundant, and they > limit usability of jBehave for two reasons: > 1. _The parameter names could be parsed directly from the step scenario > instead_. And I wish they were: I (and my testers) have frequently run into > the problem of the arguments being in the wrong order. An innocent looking > step like > {code} > @Given("a book $book written by $author") > @Alias("$author's book $book") > public void setBookAndAuthor(@Named("author") String author, @Named("book") > String book) {...} > {code} > can lead to great confusion, with the arguments getting switched. Using the > step in an example scenario can increase the confusion, as one can legally > write: > {code} > Given a book [author] written by [book] > {code} > Testers and developers alike are also confused that, while {{Given a book > Moby Dick written by Herman Melville}} works, {{Given [title] written by > [person]}} doesn't (see next point). > 2. _they inhibit reusing steps in example scenarios_; either that, or they > lead to redundant columns. > An example to illustrate this: given > {code} > @Given("a stock named $stock") > public void createStock(@Named("stock") String stock)... > {code} > I cannot reuse this step for two colums in an example: > {code} > Scenario: client creates two stocks > Given a stock named [A] > And a stock named [B] > > Examples: > |A |B | > |GOOG | AAPL | > {code} -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email