cucumberbddgherkinweb-api-testingfeature-file

Unable to parse Feature file in cucumber


I am unable to parse my feature file in cucumber while running i am getting following error, i am creating a BDD test framework to do API testing using cumber feature file concept

io.cucumber.core.gherkin.FeatureParserException: Failed to parse resource at: file:///D:/NodeApiTesting/APITestingNode/src/test/resources/functionalTests/End2End_Test.feature at io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser.parseGherkin5(GherkinVintageFeatureParser.java:40) at io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser.parse(GherkinVintageFeatureParser.java:58) at io.cucumber.core.feature.FeatureParser.parseResource(FeatureParser.java:44) at io.cucumber.core.runtime.FeaturePathFeatureSupplier.lambda$new$0(FeaturePathFeatureSupplier.java:39) at java.util.function.BiFunction.lambda$andThen$0(Unknown Source) at io.cucumber.core.resource.ResourceScanner.lambda$processResource$2(ResourceScanner.java:126) at io.cucumber.core.resource.PathScanner$ResourceFileVisitor.visitFile(PathScanner.java:67) at io.cucumber.core.resource.PathScanner$ResourceFileVisitor.visitFile(PathScanner.java:52) at java.nio.file.Files.walkFileTree(Unknown Source) at java.nio.file.Files.walkFileTree(Unknown Source) at io.cucumber.core.resource.PathScanner.findResourcesForPath(PathScanner.java:46) at io.cucumber.core.resource.PathScanner.findResourcesForUri(PathScanner.java:26) at io.cucumber.core.resource.ResourceScanner.findResourcesForUri(ResourceScanner.java:109) at io.cucumber.core.resource.ResourceScanner.scanForResourcesUri(ResourceScanner.java:86) at io.cucumber.core.runtime.FeaturePathFeatureSupplier.loadFeatures(FeaturePathFeatureSupplier.java:62) at io.cucumber.core.runtime.FeaturePathFeatureSupplier.get(FeaturePathFeatureSupplier.java:46) at io.cucumber.junit.Cucumber.(Cucumber.java:156) 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:70) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70) at org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28) at org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:90) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:76) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:49) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:526) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210) Caused by: io.cucumber.core.gherkin.vintage.internal.gherkin.ParserException$CompositeParserException: Parser errors: (1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Scenario Outline: User generates token for Authorisation' (2:2): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Given I am an authorized user' (4:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Scenario Outline: the Authorized user can Add and Remove a phone' (5:2): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Given A list of phones are available' (6:2): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'When I add a phone to store' (7:2): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Then the phone is added' (8:2): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'When I update a phone in my store' (9:2): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Then the phone is updated' (10:2): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'When I remove a phone from my store' (11:2): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Then the book is removed' (12:2): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'When I am reading my phone details' at io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.addError(Parser.java:152) at io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.matchTokenAt_0(Parser.java:491) at io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.matchToken(Parser.java:337) at io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.parse(Parser.java:137) at io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.parse(Parser.java:118) at io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.parse(Parser.java:114) at io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser.parseGherkin5(GherkinVintageFeatureParser.java:29) ... 34 more

my feature file is as follows

End2End_Test.feature

Scenario Outline: User generates token for Authorisation
    Given I am an authorized user

Scenario Outline: the Authorized user can Add and Remove a phone
    Given A list of phones are available
    When I add a phone to store
    Then the phone is added
    When I update a phone in my store
    Then the phone is updated
    When I remove a phone from my store
    Then the book is removed
    When I am reading my phone details
    Then I read my Phone Details

My runner.java file is as follows

TestRunner.java

package runners;

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/test/resources/functionalTests",
        glue = {"stepDefinitions"},
        monochrome = true,
        strict = true
)
public class TestRunner {
}

Solution

  • For Scenario Outline you need Examples.

    If you don't need example just use Scenario

    Feature: My feature name
      As a customer
      I should be able to do something
      So that I can benefit
    
     Scenario: Some test - some test description
      Given i have something
      When i do some action
      Then the results are displayed
    
    
     Scenario Outline: Some other test - scenario outline needs examples
      Given i have something
      When i do some action with <example_name>
      Then the results are displayed
    Examples:
      | example_name |
      | test         |