Maven 未运行 Cucumber 测试

问题描述 投票:0回答:1

我可以通过右键单击并运行测试来使用intellij运行测试。但无论我做什么,它都不会通过命令 mvn test 或 mvn clean test 或构建项目执行 Cucumber 步骤。

这些是一些最重要的配置:

@RunWith(Cucumber::class)
@CucumberOptions(
    features = ["src/test/resources/features"], // Path to feature files
    glue = ["com.ai.deliveries.steps"], // Package where step definitions are located
    plugin = ["pretty", "html:target/cucumber-reports"]
)
 class CucumberTest {
}

属性

<properties>
    <java.version>17</java.version>
    <kotlin.version>1.8.22</kotlin.version>
</properties>

依赖关系:

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>


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

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>7.15.0</version>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-spring</artifactId>
        <version>7.15.0</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>7.15.0</version>
        <scope>test</scope>
    </dependency>

插件:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.2.5</version>
            <configuration>
                <includes>
                    <include>**/*CucumberTest.kt</include>
                </includes>
            </configuration>
        </plugin>
java kotlin unit-testing mockito cucumber
1个回答
0
投票

您已排除

junit-jupiter-engine
,这是 JUnit 5 用于运行 JUnit 4 测试的内容。您还使用了
cucumber-junit
,它是 JUnit 4 运行程序。

包含 junit-jupiter-engine` 或使用 JUnit 5 Cucumber Engine

© www.soinside.com 2019 - 2024. All rights reserved.