黄瓜jvm无法执行function

我很喜欢使用黄瓜(今天开始)。

这看起来很简单,但我遇到了运行基本function的问题。

Feature: Proof of concept that my framework works Scenario: My first test Given this is my first step When this is my second step Then this is my final step 

我知道它没有代码可供测试,但我希望它能够返回这些场景未定义的事实。

我做了一些研究,并意识到我有一个不必要的.jar文件,我已经删除了。

我还有以下问题:

 Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/lexer/Encoding Caused by: java.lang.ClassNotFoundException: gherkin.lexer.Encoding 

还有一些来自exception的信息。

我还应该提供其他信息吗?

任何帮助,将不胜感激

在运行The Cucumber for Java书籍的第一步章节时,我遇到了同样的问题。

它说下载最新版的小黄瓜jar子(等等)

http://repo1.maven.org/maven2/info/cukes/gherkin/

下面是列表,其中,在网页上,每个都是包含jar的目录链接。 我的错误是认为最底层版本是最新版本。 不是。 对于所有其他jar子,最底层的确是最新版本。

当使用最底部的Gherkin jar时,我完全按照你的描述获得CNFX:

 Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/lexer/Encoding Caused by: java.lang.ClassNotFoundException: gherkin.lexer.Encoding 

版本号列表,如上面的网页:

 2.10.0/ 2.11.0/ 2.11.1/ 2.11.2/ 2.11.4/ 2.11.5/ 2.11.6/ 2.11.7/ 2.11.8/ 2.12.0/ 2.12.1/ 2.12.2/ 2.4.16/ 2.4.17/ 2.4.18/ 2.4.19/ 2.4.20/ 2.4.21/ 2.5.0/ 2.5.1/ 2.5.2/ 2.5.3/ 2.5.4/ 2.6.0/ 2.6.1/ 2.6.2/ 2.6.3/ 2.6.4/ 2.6.5/ 2.6.6/ 2.6.7/ 2.6.8/ 2.6.9/ 2.7.0/ 2.7.1/ 2.7.2/ 2.7.3/ 2.7.4/ 2.7.5/ 2.7.6/ 2.7.7/ 2.8.0/ 2.9.0/ 2.9.1/ 2.9.2/ 2.9.3/ 

确保CLASSPATH中有黄瓜java库。

这是一个设置问题,因为它没有找到解释小黄瓜语句所需的黄瓜类。 提供有关您在设置中包含的文件的更多信息。

而不是下载单个jar,使用包管理器下载依赖项。

使用Maven,将以下依赖项添加到pom.xml:

  io.cucumber cucumber-java 2.3.1 test   io.cucumber cucumber-junit 2.3.1 test  

NB。 这是目前的最新版本。

确保对所有Cucumber依赖项使用相同的版本。