我正在尝试使用 selenium WD 与 cucumber 和 Junit 创建一个框架。 我已经设置/下载了所有内容,但在运行时遇到问题。
当我尝试执行 JUNIT 类时,出现以下错误。有人遇到过同样的问题吗?请问您是如何解决的?
使用的 Jar 文件版本:
• cucumber 核心 4.4.0 • cucumber -html 4.4.0 • cobertura 代码覆盖率 2.1.1 • cucumber -java 4.4.0 • cucumber -junit 4.4.0 • cucumber -jvm-deps 1.0.6 • 小 cucumber 6.0.17 •Junit 4.12
错误跟踪:java.lang.NoClassDefFoundError:gherkin/IGherkinDialectProvider
最佳答案
这意味着您使用了错误的 jar 组合。 (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>
关于java - 运行 Junit 时出错 - java.lang.NoClassDefFoundError : gherkin/IGherkinDialectProvider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56900748/