[ 
https://jira.codehaus.org/browse/JBEHAVE-702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=288256#comment-288256
 ] 

Daniel Schneller edited comment on JBEHAVE-702 at 1/13/12 1:18 PM:
-------------------------------------------------------------------

Here a few examples where I would not like to create an alias for given and 
then cases, because they would be virtually identical, but for the "variant" 
word. 

A little German lesson upfront :) 

* Gegeben = Given
* Dann = then
* sei = be
* soll = should


The "sei" (be) is associated with the _first_ "Gegeben" in a German sentence, 
further conditions added with "and" do _not_ repeat it. Doing so would be very 
awkward language.

The same goes for "soll" (should). The _first_ part of a "Then" very often gets 
it, the following ones do not.

The difference to, say, English is a) the repetition and b) the order of the 
words. While in English you'd write

... then A should be 1 and B should be 2 ...

in German it would be

... dann sollte A 1 sein und B 2 sein ...


So, I agree to your idea that a new attribute of the existing Alias/es would be 
enough, because that's what it really is. What I am trying to avoid is having 
to multiply aliases to build all permutations with these variant words in front 
of them (there are a few more than "sei" and "soll", e. g. "sollte" as an 
equivalent to "soll" in most cases).

Having a way to add these concisely would increase legibility of the code and 
also help avoid copy/paste errors.

A few examples:

--------------------
Good:
Gegeben sei eine Usersession ["sei" for the first case]
Und ein Artikel im Warenkorb [no repeated "sei"]

Also good, equivalent:
Gegeben sei ein Artikel im Warenkorb ["sei" for the first case]
Und eine Usersession [no repeated "sei"]

Not Good:
Gegeben sei eine Usersession
Und sei ein Artikel im Warenkorb [repeated "sei" very awkward]
--------------------

Could be written as

@Given("eine Usersession")
@Aliases(values={"eine bestehende Session","eine aktive 
Session"},variants={"sei"})

@Given("ein Artikel im Warenkorb")
@Alias(variants={"sei"})



--------------------
Good:
Dann soll eine Meldung angezeigt werden ["soll" for first case]
Und ein Logeintrag geschrieben werden [not repeated]

Not Good:
Dann soll und ein Logeintrag geschrieben werden
Und soll eine Meldung angezeigt werden [repetition awkward]
--------------------

Could be written as

@Then("eine Meldung angezeigt werden")
@Aliases(variants={"soll","sollte"})

@Then("eine Meldung angezeigt werden")
@Aliases(variants={"soll","sollte"})


Without the variants, I would either need to write down a lot of aliases 
explicitly, or the people writing the tests would not be at their leisure to 
modify the order of the conditions they use without sacrificing natural 
language rules.

I hope I get the point across. It is a little difficult to describe the 
peculiarities of one language with the words of the other :)


                
      was (Author: dschneller):
    Here a few examples where I would not like to create an alias for given and 
then cases, because they would be virtually identical, but for the "variant" 
word. 

A little German lesson upfront :) 

* Gegeben = Given
* Dann = then
* sei = be
* soll = should


The "sei" (be) is associated with the _first_ "Gegeben" in a German sentence, 
further conditions added with "and" do _not_ repeat it. Doing so would be very 
awkward language.

The same goes for "soll" (should). The _first_ part of a "Then" very often gets 
it, the following ones do not.

The difference to, say, English is a) the repetition and b) the order of the 
words. While in English you'd write

... then A should be 1 and B should be 2 ...

in German it would be

... dann sollte A 1 sein und B 2 sein ...


So, I agree to your idea that a new attribute of the existing Alias/es would be 
enough, because that's what it really is. What I am trying to avoid is having 
to multiply aliases to build all permutations with these variant words in front 
of them (there are a few more than "sei" and "soll", e. g. "sollte" as an 
equivalent to "soll" in most cases).

Having a way to add these concisely would increase legibility of the code and 
also help avoid copy/paste errors.

A few examples:

--------------------
Good:
Gegeben sei eine Usersession ["sei" for the first case]
Und ein Artikel im Warenkorb [no repeated "sei"]

Also good, equivalent:
Gegeben sei ein Artikel im Warenkorb ["sei" for the first case]
Und eine Usersession [no repeated "sei"]

Not Good:
Gegeben sei eine Usersession
Und sei ein Artikel im Warenkorb [repeated "sei" very awkward]
--------------------

Could be written as

@Given("eine Usersession")
@Aliases(values={"eine bestehende Session","eine aktive 
Session"},variants={"sei"})

@Given("ein Artikel im Warenkorb")
@Alias(variants={"sei"})



--------------------
Good:
Dann soll eine Meldung angezeigt werden ["soll" for first case]
Und ein Logeintrag geschrieben werden [not repeated]

Not Good:
Dann soll und ein Logeintrag geschrieben werden
Und soll eine Meldung angezeigt werden [repetition awkward]
--------------------

Could be written as

@Then("eine Meldung angezeigt werden")
@Aliases(variants={"soll","sollte"})

@Then("eine Meldung angezeigt werden")
@Aliases(variants={"soll","sollte"})



I hope I get the point across. It is a little difficult to describe the 
peculiarities of one language with the words of the other :)


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