gherkin.lexer.LexingError: Lexing error on line 2:

1,628 views
Skip to first unread message

shankar garg

unread,
Jan 27, 2015, 8:13:10 AM1/27/15
to cu...@googlegroups.com
I am trying to implement Feature file in french. This is the feature file:

# language: fr
Fonctionnalité: Exemple bonjour

Scénario: Exemple bonjours
Soit: utilisateur est sur demande page d'atterrissage

PS: translation is from google translator and from https://github.com/cucumber/gherkin/blob/master/lib/gherkin/i18n.json

But i keep on getting this error:
Running com.CucumberOptions.RunCukeTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.532 sec <<< FAILURE!
initializationError(com.CucumberOptions.RunCukeTest)  Time elapsed: 0.014 sec  <<< ERROR!
cucumber.runtime.CucumberException: Error parsing feature file language.feature
        at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:133)
        at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:102)
        at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54)
        at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
        at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:201)
        at cucumber.api.junit.Cucumber.<init>(Cucumber.java:60)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
        at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:250)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: gherkin.lexer.LexingError: Lexing error on line 2: 'Fonctionnalit?: Exemple bonjour

Sc?nario: Exemple bonjours
Soit: utilisateur est sur demande page d'atterrissage
%_FEATURE_END_%'. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information.
        at gherkin.lexer.Fr.scan(Fr.java:918)
        at gherkin.lexer.I18nLexer.scan(I18nLexer.java:36)
        at gherkin.parser.Parser.parse(Parser.java:62)
        at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:131)
        ... 27 more


Results :

Tests in error:
  initializationError(com.CucumberOptions.RunCukeTest): Error parsing feature file language.feature

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0


Same code works for Danish language but ofcourse after translating to Danish.

aslak hellesoy

unread,
Jan 27, 2015, 11:07:01 AM1/27/15
to Cucumber Users
On Tue, Jan 27, 2015 at 1:13 PM, shankar garg <shnake...@gmail.com> wrote:
I am trying to implement Feature file in french. This is the feature file:


Is your file saved with UTF-8 encoding? Other encodings such as Latin1 will not work.

Aslak
 

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

shankar garg

unread,
Jan 28, 2015, 2:12:41 AM1/28/15
to cu...@googlegroups.com
Issue 1)
I changed the encoding to UTF-8, and now i see this in my feature file in french:

# language: fr

Fonctionnalité: Exemple bonjour

Scénario: Exemple bonjours
Soit: utilisateur est sur demande page d'atterrissage

and i still get the same error.

Exception in thread "main" cucumber.runtime.CucumberException: Error parsing feature file C:/Users/user/Documents/Xebia/Docs/cucumber/Book/Project/src/test/java/com/features/french.feature
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:133)
at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:102)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:201)
at cucumber.runtime.Runtime.run(Runtime.java:109)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
Caused by: gherkin.lexer.LexingError: Lexing error on line 1: '# language: fr

Fonctionnalité: Exemple bonjour

Scénario: Exemple bonjours
Soit: utilisateur est sur demande page d'atterrissage
%_FEATURE_END_%'. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information.
at gherkin.lexer.Fr.scan(Fr.java:918)
at gherkin.lexer.I18nLexer.scan(I18nLexer.java:36)
at gherkin.parser.Parser.parse(Parser.java:62)
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:131)
... 7 more

Issue 2)
When i run danish feature file:

# language: da
Egenskab: Ans�gning startside

Scenarie: website belastninger eller ikke
*: Bruger anmodes destinationsside

I get following output:
# language: da
Egenskab: Ans�gning startside

  Scenarie: website belastninger eller ikke # C:/Users/user/Documents/Xebia/Docs/cucumber/Book/Project/src/test/java/com/features/danish.feature:4
    *: Bruger anmodes destinationsside


0 Scenarios
0 Steps
0m0.000s

Question: Why i am not getting Step Definition suggestions?

Arnauld Loyer

unread,
Jan 28, 2015, 3:27:58 AM1/28/15
to cu...@googlegroups.com
1/ have a try by specifying explicitly the encoding you're using, and making sure you're saving your file with such encoding

# encoding: utf8
# language: fr

2/ Step's keywords are not suffixed by ':'

You're writting "Given I am already logged" and not "Given: I am already logged", that's the same for almost all other language.
I guess for Danish, it is not recognized as a keyword, thus no suggestion is provided.

Shankar Garg

unread,
Jan 28, 2015, 4:34:24 AM1/28/15
to cu...@googlegroups.com
For point 2, Thanks for pointing out the mistake. Apologies for stupid mistake. Its working fine now.

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-
Regards,
Shankar Garg
9873842038
Reply all
Reply to author
Forward
0 new messages