[ 
https://jira.codehaus.org/browse/JBEHAVE-720?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mauro Talevi resolved JBEHAVE-720.
----------------------------------

    Resolution: Fixed
    
> Allow parametrisation of scenarios by delimited names
> -----------------------------------------------------
>
>                 Key: JBEHAVE-720
>                 URL: https://jira.codehaus.org/browse/JBEHAVE-720
>             Project: JBehave
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 3.5.4
>            Reporter: Rui Figueira
>            Assignee: Mauro Talevi
>             Fix For: 3.6
>
>         Attachments: StepCreator.java
>
>
> I'm working on a simplification of the current parameterized scenario 
> solution. With this I want to:
>  * avoid the need of defining two different patterns for steps, one for 
> normal scenarios, and another for parameterized scenarios.
>  * be able to use column names in Examples tables that differ from the 
> parameter names that were specified in the step annotation
>  * avoid having to annotate fields with @Named in parameterized step methods
> Take the following steps and scenario, for example:
>  
> {code:title=ParameterizedStory.java}
> public class ParameterizedStory extends JUnitStory {
>   public static class ParamsSteps {
>     
>     private String user;    
>     private Set<String> products; // null means no cart...
>     @BeforeScenario
>     public void init() {
>       user = null;
>       products = null;
>     }
>     
>     @Given("$user is logged in")
>     public void loggedIn(String user) {
>       this.user = user;
>     }
>     
>     @Given("$customer has a cart")
>     public void aCustomerHasACart(String customer) {
>       assertThat(user, notNullValue());
>       assertThat(customer, equalTo(user));
>       if (products == null) products = new TreeSet<String>();
>     }
>      
>     @When("a $product is added to the cart")
>     public void aProductIsAddedToCart(String product) {
>       assertThat(products, notNullValue());
>       products.add(product);
>     }
>     
>     @Then("cart contains $product")
>     public void cartContains(String product) {
>       assertThat(products, notNullValue());
>       assertTrue(products.contains(product));
>     }
>   }
>   public ParameterizedStory() {
>     // Making sure this doesn't output to the build while it's running
>     useConfiguration(new MostUsefulConfiguration()
>       .useStoryReporterBuilder(new StoryReporterBuilder()
>       .withFormats(Format.CONSOLE)
>       .withFailureTrace(true)
>       .withFailureTraceCompression(false))
>       .usePendingStepStrategy(new FailingUponPendingStep())
>       .useFailureStrategy(new RethrowingFailure()));
>   }
>   
>   @Override
>   public List<CandidateSteps> candidateSteps() {
>     return new InstanceStepsFactory(configuration(), new 
> ParamsSteps()).createCandidateSteps(); 
>   }
> }
> {code}
> {code:title=parameterized_story.story}
> Scenario: Use flexible parameters with examples table
> Given <client> is logged in
> And <client> has a cart
> When a <item> is added to the cart
> Then cart contains <item>
> Examples:
> |client|item|
> |Rui|chocolate|
> |Figueira|car|
> {code}
> The "Given $user is logged in" step pattern will match "Given <client> is 
> logged in", and user parameter will be set to client column values.
> The main idea is that <client>, instead of represent a named parameter, 
> represents a placeholder, and that placeholder should be replaced with 
> whether value exists for it in the examples table. Then, after replacing the 
> placeholder with the corresponding value, it will then match with the given 
> step pattern, and $user will be set to the correct value.
> I have a working version available at 
> https://github.com/ruifigueira/jbehave-core/commit/a4107a3ac899c4b952746781f785cba9a97c659c,
>  that can be used to test the scenario above.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.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


Reply via email to