gherkin.lexer.LexingError:第1行的Lexing错误

时间:2015-11-12 19:50:51

标签: eclipse cucumber

当我用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

3 个答案:

答案 0 :(得分:7)

您需要执行以下操作:A)删除Feature :Scenario Outline :个关键字中的空格;和B)将场景大纲更改为场景(或添加缺少的大纲示例)。

如果您运行此功能:

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

然后,黄瓜将输出待完成的步骤定义:

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

答案 1 :(得分:1)

这是一个小黄瓜语法错误:关键字和冒号之间不能有空格。


Actual = Feature:
预期=功能:

实际=方案大纲:
预期=方案大纲:


方案概述:将始终与示例一起使用,

现在何时使用方案大纲;何时使用方案:

方案概述:

当您必须测试具有多组数据的同一屏幕时使用此

场景:

当您必须使用一组数据或没有数据测试一个方案时使用此方法

您的情况:

您正在测试功能,没有数据集。因此,您应该使用方案而不是方案大纲。

预期功能:

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

答案 2 :(得分:0)

只是因为错误原因不仅仅是orde提到的事情。

END

检查“Then”关键字是否应该采用正确的语法方式。这该死的确定会导致词汇错误。