在 mvn 测试之后,由于某种原因我看到“测试运行:0”

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

我正在尝试使用“maven test”运行我的测试,但我总是收到测试运行:0,失败:0,错误:0,跳过:0

找不到问题。我猜问题出在 eather pom 或 runner

Runner 自行工作并运行所有测试

package runners;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.IncludeTags;
import org.junit.runner.RunWith;

@IncludeEngines("cucumber")
@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/test/resources/features",
        glue = "cucumber.steps"
)

public class RunCucumberTest {

}

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>TestAutomationProject</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>

        <!--        &lt;!&ndash; https://mvnrepository.com/artifact/junit/junit &ndash;&gt;-->
        <!--        <dependency>-->
        <!--            <groupId>junit</groupId>-->
        <!--            <artifactId>junit</artifactId>-->
        <!--            <version>4.12</version>-->
        <!--            <scope>test</scope>-->
        <!--        </dependency>-->


        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.12.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.9.1</version>
            <scope>test</scope>
        </dependency>

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

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>7.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-api</artifactId>
            <version>1.9.2</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

<!--    <build>-->
<!--        <plugins>-->
<!--            <plugin>-->
<!--                <groupId>org.apache.maven.plugins</groupId>-->
<!--                <artifactId>maven-surefire-plugin</artifactId>-->
<!--                <version>3.2.5</version>-->
<!--                <configuration>-->
<!--                    <includes>-->
<!--                        <include>**/*RunCucumberTest.java</include>-->
<!--                    </includes>-->
<!--                </configuration>-->
<!--            </plugin>-->
<!--        </plugins>-->
<!--    </build>-->

</project>

我在 pom、runner 等方面尝试了很多更改。没有用;c

测试和运行器放置在 src/test/java

java maven selenium-webdriver junit cucumber
1个回答
0
投票

您正在使用与 JUnit 4 集成的

cucumber-junit
。但是,由于您使用的是 JUnit 5,Surefire 将不会运行 JUnit 4 测试。您需要添加 JUnit Vintage 引擎或 Cucumber 的 JUnit 5 集成。

参见工作示例:

https://github.com/cucumber/cucumber-java-骨骼

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