Cucumber JVM error parsing the Background tag

638 views
Skip to first unread message

Vikram Upadhya

unread,
Dec 5, 2016, 6:24:18 AM12/5/16
to Cukes
Hi All,

For the Attached Feature i get a error. is this specific to Background tag?.

Feature: Display Alarm & Audio



Narrative: As a clinician I want Visual indication of high priority alarm symbol with Audio indication for US1 compressed parameter block 
so that it helps me in clinical decision making

Background: verify Alarms are displayed 
Given Alarm is enabled
And Audio is enabled

cucumber.runtime.CucumberException: Error parsing feature file Feature/Alarm.feature
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:133)
at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:104)
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:235)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:60)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
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:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: gherkin.parser.ParseError: Parse error at Feature/Alarm.feature:9. Found background when expecting one of: examples, feature, scenario, scenario_outline, tag. (Current getState: tag).
at gherkin.parser.Parser$Machine.event(Parser.java:207)
at gherkin.parser.Parser.event(Parser.java:159)
at gherkin.parser.Parser.background(Parser.java:103)
at gherkin.lexer.En.scan(En.java:753)
at gherkin.lexer.I18nLexer.scan(I18nLexer.java:36)
at gherkin.parser.Parser.parse(Parser.java:62)
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:131)
... 22 more


Build Details:
cucumber-html-0.2.3.jar
cucumber-jvm-deps-1.0.5.jar
gherkin-2.12.2.jar
gherkin-4.0.0.jar
gherkin-jvm-deps-1.0.4.jar
hamcrest-all-1.3.jar
hamcrest-core-1.3.jar
cucumber-core-1.2.4.jar
cucumber-java-1.2.4.jar
cucumber-junit-1.2.4.jar

Björn Rasmusson

unread,
Dec 5, 2016, 1:16:03 PM12/5/16
to Cukes

This error says that you have a tag (@tag_name) before the background keyword, something lik:

 
@foo
 
Background: ...
 

If you remove the tag before the background keyword, the feature should work.

Regards
Björn


 

sachin bhangade

unread,
Dec 6, 2016, 12:20:20 AM12/6/16
to Cukes
In your feature file, you forgot to use Scenario or Scenario Outline. After Background keyword there should be some Scenario. There is no scenario to execute at this moment in your feature file.

Vikram Upadhya

unread,
Dec 7, 2016, 2:16:12 AM12/7/16
to Cukes
Thanks guys, this Worked.

Feature: Checking tags for Requirement Update

Narrative:  To test background tags

Background: 
Given TestA

@MISC_TAGS

Scenario:  TestScenario#6
When  TestB
Then  TestC

@test
Scenario: TestScenario#6_1
When  TestB
Then i must try to automate

@test
Scenario: TestScenario#6_2
When  TestB
Then two files are created
Reply all
Reply to author
Forward
0 new messages