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

Daniel Schneller updated JBEHAVE-702:
-------------------------------------

    Attachment: jbehave-702-1.zip

Alright, I have come up with something that would work for me. Feedback 
appreciated :)
It is based on the premise that the usual case would be to have some parts of a 
step be optional or picked from a list of variants like so.

*Example 1: two variants*
{code:java}
@When("$A plus $B")
@Alias("$A + $B")
{code}
could become:
{noformat}
@When("@$A {plus|+}")
{noformat}

*Example 2: optional phrases with alternatives*
{code:java}
@Then("the result be $x")
@Alias(values={"the result must be $x",
               "the result should be $x",
               "the result has to be $x"})
{code}
could be written as
{code:java}
@Then("the result {must |should |has to |}be")
{code}
Here the trailing | introduces an "empty" variant, essentially making the 
pattern optional.

*Example 3: multiple patterns in one step*
It is possible to have more than one pattern group in a step description. 
{code:java}
@Then("A {must |has to |is to |} be $x unless {it's|it is} {part of|contained 
in} {list |}$y")
{code}
In this example writing this with aliases would result in 31 aliased variants 
(4*2*2*2 permutations). 


I will attach a small ZIP file containing a modified Steps class and the 
permutation builder I have hacked together. As said before, any feedback is 
welcome.

                
> Allow injection of the "Steps" class to customize its behavior
> --------------------------------------------------------------
>
>                 Key: JBEHAVE-702
>                 URL: https://jira.codehaus.org/browse/JBEHAVE-702
>             Project: JBehave
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 3.5.4
>            Reporter: Daniel Schneller
>              Labels: i18n, wish
>         Attachments: jbehave-702-1.zip, Steps.java, Steps.java
>
>
> To get more natural German story texts, it would be very helpful if the 
> Steps.listCandidates() method could be amended.
> This would allow for automatically generating slight variations of the texts 
> without having to specify them all as aliases. Currently I am doing this:
> @Then("soll foo bar with $xyz")
> @Aliases(values = {
>       "foo bar with $xyz",
>       "soll foo bar: $xyz",
>       "foo bar: $xyz" })
> The word "soll" is made optional this way. The reasoning behind this is that 
> when using "And" it is more natural to write
> Then soll something else
> And foo bar with $xyz
> instead of
> Then soll something else
> And soll foo bar with $xyz
> It would be very nice to not have define aliases for all these variants, 
> because it makes the code harder to maintain. Instead, I though I'd add this 
> dynamically, the same way annotated Aliases are, but it seems this 
> functionality would require providing a new subclass of 
> org.jbehave.core.steps.Steps which I cannot see how to do.
> I suggest a change like this:
> 1) In org.jbehave.core.steps.Steps add another call in listCandidates() after 
> each of the addCandidatesFromAliases(...) like 
> addCustomDerivedCandidates(...) with the same signature and a protected empty 
> default implementation.
> 2) Allow configuration to specify a custom subclass of 
> org.jbehave.core.steps.Steps. In there custom additions to the candidates 
> list could be made, like the one I described.

--
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