gherkin.lexer.LexingError: Lexing error on line 1
gherkin.lexer.LexingError: Lexing error on line 1
当我 运行 我的第一个 Cucumber 测试文件时,我遇到了这个异常如何解决这个问题?
Exception in thread "main" cucumber.runtime.CucumberException: Error parsing feature file D:/intalled/CucumberConcepts/src/cucumber/features/myfeature.feature
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:123)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:52)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:33)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:143)
at cucumber.runtime.Runtime.run(Runtime.java:107)
at cucumber.api.cli.Main.run(Main.java:26)
at cucumber.api.cli.Main.main(Main.java:16)
原因:gherkin.lexer.LexingError:第 1 行的 Lexing 错误:'功能:我的框架有效的概念证明
这是我的测试文件
Feature : Proof of concept that my framework works
Scenario Outline : My first Test
Given this is my first test
When This is my second step
Then This is the final step
您需要做几件事:A) 删除 Feature :
和 Scenario Outline :
关键字中的空格; B) 将 Scenario Outline 更改为 Scenario(或为大纲添加缺失的示例)。
如果您运行此功能:
Feature: Proof of concept that my framework works
Scenario: My first Test
Given this is my first test
When This is my second step
Then This is the final step
然后cucumber会输出待完成的步骤定义:
You can implement step definitions for undefined steps with these snippets:
Given(/^this is my first test$/) do
pending # Write code here that turns the phrase above into concrete actions
end
When(/^This is my second step$/) do
pending # Write code here that turns the phrase above into concrete actions
end
Then(/^This is the final step$/) do
pending # Write code here that turns the phrase above into concrete actions
end
just to addon 错误的原因不只是orde提到的东西
Feature: Proof of concept that my framework works
Scenario: My first Test
Given this is my first test
When This is my second step
THEN This is the final step
检查 "Then" 关键字是否全部大写,这应该符合正确的语法方式。这该死的肯定会导致词法错误。
这是一个 Gherkin 语法错误:关键字和冒号之间不能有 space。
实际 = 特征:
预期 = 特征:
实际 = 场景大纲:
预期 = 场景大纲:
场景大纲:将始终与示例一起使用,
现在什么时候使用场景大纲:以及什么时候使用场景: ?
场景大纲:
当您必须使用多组数据测试同一屏幕时使用
场景:
当你必须用一组数据或没有数据测试一个场景时使用
你的案例:
您正在测试没有数据集的功能。所以你应该使用场景而不是场景大纲。
预期功能:
Feature: Proof of concept that my framework works
Scenario: My first Test
Given this is my first test
When This is my second step
Then This is the final step
当我 运行 我的第一个 Cucumber 测试文件时,我遇到了这个异常如何解决这个问题?
Exception in thread "main" cucumber.runtime.CucumberException: Error parsing feature file D:/intalled/CucumberConcepts/src/cucumber/features/myfeature.feature
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:123)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:52)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:33)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:143)
at cucumber.runtime.Runtime.run(Runtime.java:107)
at cucumber.api.cli.Main.run(Main.java:26)
at cucumber.api.cli.Main.main(Main.java:16)
原因:gherkin.lexer.LexingError:第 1 行的 Lexing 错误:'功能:我的框架有效的概念证明
这是我的测试文件
Feature : Proof of concept that my framework works
Scenario Outline : My first Test
Given this is my first test
When This is my second step
Then This is the final step
您需要做几件事:A) 删除 Feature :
和 Scenario Outline :
关键字中的空格; B) 将 Scenario Outline 更改为 Scenario(或为大纲添加缺失的示例)。
如果您运行此功能:
Feature: Proof of concept that my framework works
Scenario: My first Test
Given this is my first test
When This is my second step
Then This is the final step
然后cucumber会输出待完成的步骤定义:
You can implement step definitions for undefined steps with these snippets:
Given(/^this is my first test$/) do
pending # Write code here that turns the phrase above into concrete actions
end
When(/^This is my second step$/) do
pending # Write code here that turns the phrase above into concrete actions
end
Then(/^This is the final step$/) do
pending # Write code here that turns the phrase above into concrete actions
end
just to addon 错误的原因不只是orde提到的东西
Feature: Proof of concept that my framework works
Scenario: My first Test
Given this is my first test
When This is my second step
THEN This is the final step
检查 "Then" 关键字是否全部大写,这应该符合正确的语法方式。这该死的肯定会导致词法错误。
这是一个 Gherkin 语法错误:关键字和冒号之间不能有 space。
实际 = 特征:
预期 = 特征:
实际 = 场景大纲:
预期 = 场景大纲:
场景大纲:将始终与示例一起使用,
现在什么时候使用场景大纲:以及什么时候使用场景: ?
场景大纲:
当您必须使用多组数据测试同一屏幕时使用
场景:
当你必须用一组数据或没有数据测试一个场景时使用
你的案例:
您正在测试没有数据集的功能。所以你应该使用场景而不是场景大纲。
预期功能:
Feature: Proof of concept that my framework works
Scenario: My first Test
Given this is my first test
When This is my second step
Then This is the final step