黄瓜4.3.1的线程“主”中的异常java.lang.NoClassDefFoundError:gherkin / formatter / Formatter

时间:2019-08-28 08:45:09

标签: maven cucumber testng cucumber-jvm gherkin

我正在将黄瓜Java 4.3.1与小黄瓜5.1.0一起使用 当我使用maven命令“ mvn test”执行脚本时,它的工作正常,但是当我尝试执行单个功能文件时,它给出了“线程“主”中的异常java.lang.NoClassDefFoundError:gherkin / formatter / Formatter”

我尝试使用不同版本的Gherkins依赖项,但仍然遇到相同的问题。以下是我的Maven依赖项

        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>4.0.0</version>
            <scope>test</scope>
        </dependency>


        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.3.1</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.25</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>4.3.1</version>
        </dependency>

        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-cucumber3-jvm</artifactId>
            <version>2.7.0</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.6</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin-jvm-deps</artifactId>
            <version>1.0.4</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin</artifactId>
            <version>5.1.0</version>
        </dependency>

    </dependencies>

1 个答案:

答案 0 :(得分:0)

尝试仅添加4个以下的jar,然后直接执行功能文件。它可以通过Eclipse IDE和mvn test命令为我工作

mvn test -Dcucumber.options=src/test/java/features/test.feature

依赖项:

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>4.2.2</version>
</dependency>
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-core</artifactId>
    <version>4.2.2</version>
</dependency>
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>4.2.2</version>
</dependency>
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.14.3</version>
    <scope>test</scope>
</dependency>