当我在 运行 步骤定义文件时出现初始化错误

Getting initialization Error, when i am running Step definition file

Cucumber 配置设置:

我在 运行 步骤定义文件

时收到初始化错误
java.lang.NoClassDefFoundError: cucumber/deps/com/thoughtworks/xstream/converters/ConverterRegistry

以下依赖项用于构建:

cucumber-picocontainer:1.2.5 小黄瓜:2.12.2 黄瓜报告:1.0 黄瓜-jvm-dep:1.0.5 黄瓜联合:1.2.5 黄瓜jvm:1.2.5 黄瓜 - java : 1.2.5

运行程序文件:cuccumberOptions (特征 = "Features", 胶水 = "package name of step definition file" )

请查看 Cucumber docs 您需要使用 Cucumber(及其最新版本)的依赖项。

例如,您不需要导入小黄瓜,因为它是一个传递依赖项。 在您的情况下,您应该只需要 cucumber-java、cucumber-junit 和 cucumber-picocontainer。确保对所有这些依赖项使用相同的版本。

声明一次版本:

<properties>
   <cucumber.version>4.3.1</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>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>${cucumber.version}</version>
    <scope>test</scope>
</dependency>

转到 Windows>首选项>已安装的 JRE 并添加 jre 的路径并单击应用。