gwen-interpreter / gwen

Core Gwen interpreter
https://gweninterpreter.org
Apache License 2.0
34 stars 7 forks source link

Unable to write feature specs with other Cucumber's spoken languages #53

Closed dfriquet closed 4 years ago

dfriquet commented 4 years ago

Hello there,

Gwen is leaving the PoC status to become a first-class citizen in our software tool belt. One last thing bothers us so far: we work with native French-speaking end users and we would like to write our feature specs in French — not the @StepDef meta specs, just the user-facing feature specs.

It seems that the Gwen interpreter uses Cucumber's Gherkin parser, and Cucumber supports a lot of spoken languages. Have you succeeded in using other keywords than Given/When/Then with Cucumber syntax # language: fr for instance?

I get errors like

ERROR - Gherkin syntax error: No value found for 'Soit'

or, with the "universal" * syntax:

ERROR - Gherkin syntax error: No value found for '*'

Do I do anything wrong or is it unsupported yet?

Best regards, -- David.

bjuric commented 4 years ago

Hi David,

That is one thing we haven't done and will need to start looking into. Will keep you posted.

bjuric commented 4 years ago

Hi @dfriquet , we've started work on this. To help us test before release, can you please fully translate the following feature to French? Thanks

 Feature: Google search

Scenario: Lucky Google search
    Given I have Google in my browser
     When I do a search for "gwen-web automation"
     Then I should find a Gwen page
dfriquet commented 4 years ago

Nice! Are you always that efficient? :+1:

Here is my contribution:

Fonctionnalité: recherche Google

      Scénario: recherche Google fructueuse
    Étant donné mon navigateur ouvert sur Google
          Quand je recherche "gwen-web automation"
          Alors je dois trouver une page concernant Gwen

I have kept the "keyword alignment" you used, so that you can easily distinguish them from the steps without learning French ;-)

Hope it helps.

bjuric commented 4 years ago

Thanks for that @dfriquet

We're almost there. Here's a preview of the generated reports:

Screen Shot 2020-03-27 at 12 47 07 am

Note however that the dialect can only be specified in feature files. Gherkin keywords and the predefined Gwen DSL in meta must remain in English. The sample meta for the above is:

Feature: Google search meta

@StepDef
@Context
Scenario: mon navigateur ouvert sur Google
    Given I start a new browser
     When I navigate to "http://www.google.com"
     Then the page title should be "Google"

@StepDef
@Action
Scenario: je recherche "<query>"
    Given the search field can be located by name "q"
     When I enter "$<query>" in the search field
     Then the page title should contain "$<query>"

@StepDef
@Assertion
Scenario: je dois trouver une page concernant Gwen
    Given link 1 can be located by css selector ".r > a"
     When I click link 1
     Then the current URL should match regex ".+[G|g]wen.*"
dfriquet commented 4 years ago

That's exactly what we need… Merci !

bjuric commented 4 years ago

You will also be able to specify the following setting. Specifying it will make it the default dialect so you don't have to specify the # language header in every feature file.

gwen.feature.dialect = fr

If you do specify the # langauge header in features it will override this setting. The default value of this setting is en.

bjuric commented 4 years ago

Support for Gherkin's spoken languages has been implemented and released in gwen-web v2.42.0. Also included is a change to treat universal * keyword as And.

@dfriquet Please evaluate and close this issue when ready.

dfriquet commented 4 years ago

It works like a charm :bowing_man: