【发布时间】:2020-07-17 05:41:12
【问题描述】:
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(Native Method) 在 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.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:526) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210) 引起:io.cucumber.core.gherkin.vintage.internal.gherkin.ParserException$CompositeParserException:解析器错误: (1:1):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“场景大纲:用户生成授权令牌” (2:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“鉴于我是授权用户” (4:1):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“场景大纲:授权用户可以添加和删除电话” (5:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“给定电话列表可用” (6:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“当我将手机添加到商店时” (7:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“然后电话被添加” (8:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“当我在商店中更新手机时” (9:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“然后手机更新” (10:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“当我从商店中取出手机时” (11:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“然后这本书被删除” (12:2):预期:#EOF、#Language、#TagLine、#FeatureLine、#Comment、#Empty,得到“当我阅读手机详细信息时” 在 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 {
}
【问题讨论】:
标签: cucumber bdd gherkin web-api-testing feature-file