我正在使用 Cucumber 框架来编写我的 ATDD。尝试运行 Cucumber 测试时出现以下错误。
[INFO] Running my.package.RunCukesTests
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.146 s <<< FAILURE! - in my.package.RunCukesTests
[ERROR] initializationError(my.package.RunCukesTests) Time elapsed: 0.005 s <<< ERROR!
java.lang.NoClassDefFoundError: io/cucumber/stepexpression/TypeRegistry
Caused by: java.lang.ClassNotFoundException: io.cucumber.stepexpression.TypeRegistry
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] RunCukesTests.initializationError » NoClassDefFound io/cucumber/stepexpression...
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
以下是 Cucumber 依赖项:
<properties>
<cucumber.version>3.0.2</cucumber.version>
</properties>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
RunCuckesTest.java
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = { "html:target/test_results/html/TestRunner/cucumber-html-report",
"json:target/test_results/json/TestRunner-reports.json", "pretty" }, tags = { "" }, features = {
"src/test/resources/" }, glue = {
"glue/package/steps",
"glue/package1/steps" })
public class RunCukesTests {
}
在具有类似异常的线程中搜索时,我发现这可能是由于多个依赖项或使用不同版本不匹配而导致的。但是在这里我使用的是相同的版本,当我使用相同的版本时,我不确定问题出在哪里。
非常感谢任何帮助。提前致谢。