运行Junit时出错-java.lang.NoClassDefFoundError:gherkin / IGherkinDialectProvider

时间:2019-07-05 09:56:50

标签: java selenium-webdriver junit cucumber gherkin

我正在尝试使用硒WD与黄瓜和Junit创建一个框架。 我已经设置/下载了所有文件,但运行时遇到了问题。

当我尝试执行JUNIT类时,出现以下错误。有没有人遇到过同样的问题,请问您如何解决?

使用的Jar文件版本:

•黄瓜核4.4.0 •Cucumber-html 4.4.0 •cobertura代码覆盖率2.1.1 •黄瓜Java 4.4.0 •黄瓜junit 4.4.0 •黄瓜-jvm-deps 1.0.6 •小黄瓜6.0.17 •Junit 4.12

错误跟踪:java.lang.NoClassDefFoundError:gherkin / IGherkinDialectProvider

1 个答案:

答案 0 :(得分:0)

这意味着您使用了错误的罐子组合。 (Afaik Cucumber-jvm v4不使用Gherkin 6。)

请注意,Cucumber建议使用程序包管理器(Maven或Gradle),以防止出现此问题并确保获得正确的传递依赖项。

查看Cucumber docs中的安装说明,以了解所需的依赖项。

对于Maven:

If you are going to use the lambda expressions API (Java 8) to write the step definitions, 
add the following dependency to your pom.xml:

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java8</artifactId>
    <version>4.3.1</version>
    <scope>test</scope>
</dependency>

Otherwise, to write them using annotated methods, 
add the following dependency to your pom.xml:

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>4.3.1</version>
    <scope>test</scope>
</dependency>