无法解析黄瓜中的特征文件
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: 解析资源失败:file:///D:/NodeApiTesting/APITestingNode/src/test/resources/functionalTests/End2End_Test.feature
在 io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser.parseGherkin5(GherkinVintageFeatureParser.java:40)
在 io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser.parse(GherkinVintageFeatureParser.java:58)
在 io.cucumber.core.feature.FeatureParser.parseResource(FeatureParser.java:44)
在 io.cucumber.core.runtime.FeaturePathFeatureSupplier.lambda$new$0(FeaturePathFeatureSupplier.java:39)
在 java.util.function.BiFunction.lambda$andThen$0(未知来源)
在 io.cucumber.core.resource.ResourceScanner.lambda$processResource$2(ResourceScanner.java:126)
在 io.cucumber.core.resource.PathScanner$ResourceFileVisitor.visitFile(PathScanner.java:67)
在 io.cucumber.core.resource.PathScanner$ResourceFileVisitor.visitFile(PathScanner.java:52)
在 java.nio.file.Files.walkFileTree(来源不明)
在 java.nio.file.Files.walkFileTree(来源不明)
在 io.cucumber.core.resource.PathScanner.findResourcesForPath(PathScanner.java:46)
在 io.cucumber.core.resource.PathScanner.findResourcesForUri(PathScanner.java:26)
在 io.cucumber.core.resource.ResourceScanner.findResourcesForUri(ResourceScanner.java:109)
在 io.cucumber.core.resource.ResourceScanner.scanForResourcesUri(ResourceScanner.java:86)
在 io.cucumber.core.runtime.FeaturePathFeatureSupplier.loadFeatures(FeaturePathFeatureSupplier.java:62)
在 io.cucumber.core.runtime.FeaturePathFeatureSupplier.get(FeaturePathFeatureSupplier.java:46)
在 io.cucumber.junit.Cucumber.(Cucumber.java:156)
在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
在 sun.reflect.NativeConstructorAccessorImpl.newInstance(未知来源)
在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(来源不明)
在 java.lang.reflect.Constructor.newInstance(来源不明)
在 org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
在 org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
在 org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
在 org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
在 org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
在 org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28)
在 org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19)
在 org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:90)
在 org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:76)
在 org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:49)
在 org.eclipse.jdt.internal.junit.运行ner.RemoteTestRunner.运行 测试(RemoteTestRunner.java:526)
在 org.eclipse.jdt.internal.junit.运行ner.RemoteTestRunner.运行 测试(RemoteTestRunner.java:770)
在 org.eclipse.jdt.internal.junit.运行ner.RemoteTestRunner.运行(RemoteTestRunner.java:464)
在 org.eclipse.jdt.internal.junit.运行ner.RemoteTestRunner.main(RemoteTestRunner.java:210)
原因:io.cucumber.core.gherkin.vintage.internal.gherkin.ParserException$CompositeParserException:解析器错误:
(1:1):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Scenario Outline: User generates token for Authorisation'
(2:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Given I am an authorized user'
(4:1):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Scenario Outline: the Authorized user can Add and Remove a phone'
(5:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Given A list of phones are available'
(6:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'When I add a phone to store'
(7:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Then the phone is added'
(8:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'When I update a phone in my store'
(9:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Then the phone is updated'
(10:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'When I remove a phone from my store'
(11:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Then the book is removed'
(12:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'When I am reading my phone details'
在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.addError(Parser.java:152)
在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.matchTokenAt_0(Parser.java:491)
在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.matchToken(Parser.java:337)
在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.parse(Parser.java:137)
在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.parse(Parser.java:118)
在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.parse(Parser.java:114)
在 io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser.parseGherkin5(GherkinVintageFeatureParser.java:29)
... 还有 34 个
我的特征文件如下
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
我的runner.java文件如下
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 {
}
对于 Scenario Outline
你需要 Examples
.
如果您不需要示例,只需使用 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 |
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: 解析资源失败:file:///D:/NodeApiTesting/APITestingNode/src/test/resources/functionalTests/End2End_Test.feature 在 io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser.parseGherkin5(GherkinVintageFeatureParser.java:40) 在 io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser.parse(GherkinVintageFeatureParser.java:58) 在 io.cucumber.core.feature.FeatureParser.parseResource(FeatureParser.java:44) 在 io.cucumber.core.runtime.FeaturePathFeatureSupplier.lambda$new$0(FeaturePathFeatureSupplier.java:39) 在 java.util.function.BiFunction.lambda$andThen$0(未知来源) 在 io.cucumber.core.resource.ResourceScanner.lambda$processResource$2(ResourceScanner.java:126) 在 io.cucumber.core.resource.PathScanner$ResourceFileVisitor.visitFile(PathScanner.java:67) 在 io.cucumber.core.resource.PathScanner$ResourceFileVisitor.visitFile(PathScanner.java:52) 在 java.nio.file.Files.walkFileTree(来源不明) 在 java.nio.file.Files.walkFileTree(来源不明) 在 io.cucumber.core.resource.PathScanner.findResourcesForPath(PathScanner.java:46) 在 io.cucumber.core.resource.PathScanner.findResourcesForUri(PathScanner.java:26) 在 io.cucumber.core.resource.ResourceScanner.findResourcesForUri(ResourceScanner.java:109) 在 io.cucumber.core.resource.ResourceScanner.scanForResourcesUri(ResourceScanner.java:86) 在 io.cucumber.core.runtime.FeaturePathFeatureSupplier.loadFeatures(FeaturePathFeatureSupplier.java:62) 在 io.cucumber.core.runtime.FeaturePathFeatureSupplier.get(FeaturePathFeatureSupplier.java:46) 在 io.cucumber.junit.Cucumber.(Cucumber.java:156) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(未知来源) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(来源不明) 在 java.lang.reflect.Constructor.newInstance(来源不明) 在 org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104) 在 org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86) 在 org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70) 在 org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37) 在 org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70) 在 org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28) 在 org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19) 在 org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:90) 在 org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:76) 在 org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:49) 在 org.eclipse.jdt.internal.junit.运行ner.RemoteTestRunner.运行 测试(RemoteTestRunner.java:526) 在 org.eclipse.jdt.internal.junit.运行ner.RemoteTestRunner.运行 测试(RemoteTestRunner.java:770) 在 org.eclipse.jdt.internal.junit.运行ner.RemoteTestRunner.运行(RemoteTestRunner.java:464) 在 org.eclipse.jdt.internal.junit.运行ner.RemoteTestRunner.main(RemoteTestRunner.java:210) 原因:io.cucumber.core.gherkin.vintage.internal.gherkin.ParserException$CompositeParserException:解析器错误: (1:1):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Scenario Outline: User generates token for Authorisation' (2:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Given I am an authorized user' (4:1):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Scenario Outline: the Authorized user can Add and Remove a phone' (5:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Given A list of phones are available' (6:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'When I add a phone to store' (7:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Then the phone is added' (8:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'When I update a phone in my store' (9:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Then the phone is updated' (10:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'When I remove a phone from my store' (11:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'Then the book is removed' (12:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到 'When I am reading my phone details' 在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.addError(Parser.java:152) 在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.matchTokenAt_0(Parser.java:491) 在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.matchToken(Parser.java:337) 在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.parse(Parser.java:137) 在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.parse(Parser.java:118) 在 io.cucumber.core.gherkin.vintage.internal.gherkin.Parser.parse(Parser.java:114) 在 io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser.parseGherkin5(GherkinVintageFeatureParser.java:29) ... 还有 34 个
我的特征文件如下
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
我的runner.java文件如下
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 {
}
对于 Scenario Outline
你需要 Examples
.
如果您不需要示例,只需使用 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 |