Cannot use the same step multiple times in a scenario
-----------------------------------------------------

                 Key: JBEHAVE-652
                 URL: https://jira.codehaus.org/browse/JBEHAVE-652
             Project: JBehave
          Issue Type: Bug
    Affects Versions: 3.5.4
            Reporter: Andreas Ebbert-Karroum


I have a story that looks like this:

{code}
Meta:
@themes Book

Scenario:

As a member I can return all my borrowed books at once.

Given an empty library
And a user <user> has borrowed books <isbns>
And a user <user2> has borrowed books <isbns2>

When user <user> returns all his books

Then books <isbns> are not borrowed anymore by user <user>
And books <isbns2> are still borrowed by user <user2>

Examples:    
    
| user            | isbns                 | user2           | isbns2            
    |
| us...@dings.com | 0321293533            |                 |                   
    |
| us...@dings.com | 0321293533            | us...@dings.com | 1234567962        
    |
| us...@dings.com | 0321293533            | us...@dings.com | 0321293533        
    |
| us...@dings.com | 0321293533 1234567962 |                 |                   
    |
| us...@dings.com | 0321293533 1234567962 | us...@dings.com | 1234567962        
    |
| us...@dings.com | 0321293533 1234567962 | us...@dings.com | 0321293533 
1234567962 |
{code}

As you can see, I would like to reuse a step two times, with different 
parameter sets (user/isbns and user2/isbns2). JBehave forces me to wrote two 
different step definitions (two annotated methods), because the @Named actually 
pulls the value straight out of the examples table, regardless, of what 
parameters match the step.

So I am forced to do this. Very ugly, IMHO.

{code}
@Given("a user <user> has borrowed books <isbns>")
public void createListOfBorrowedBooks(@Named("user") String user, 
@Named("isbns") String isbns) throws SQLException{
}

@Given("a user <user2> has borrowed books <isbns2>")
public void createListOfBorrowedBooks2(@Named("user2") String user, 
@Named("isbns2") String isbns) throws SQLException{
        createListOfBorrowedBooks(user, isbns);
}
{code}

I regarded the steps as something similar to a method or keyword, but now I 
realize that there are subtle differences.

As weird as Robot Frameworks syntax and grammar might be sometimes, it is 
coping much better with these circumstances.









--
This message is automatically generated by JIRA.
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


Reply via email to