Maven surefire插件无法检测Junit5测试

坎南·埃卡纳特

我已经看过Surefire并没有进行Junit 5的测试以及一些相关的问题,但是Junit5的情况正在迅速发展,这些建议似乎不再起作用。

Maven:3.3.9我的pom.xml中包含以下内容

<dependencies>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>23.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.7</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.0.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-surefire-provider</artifactId>
        <version>1.0.2</version>
        <scope>test</scope>
    </dependency>
    <!-- Only required to run tests in an IDE that bundles an older version -->
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-launcher</artifactId>
        <version>1.0.2</version>
        <scope>test</scope>
    </dependency>
    <!-- Only required to run tests in an IDE that bundles an older version -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.0.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>4.12.2</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20.1</version>
        </plugin>
    </plugins>
</build>

如您所见,这些是Junit5的最新可能版本,但是当我运行mvn install命令时,它仍未检测到任何测试。

有什么建议么?可以肯定的是,它不是Maven + surefire插件+ Junit5 api + Junit5引擎不能一起玩,并且很乐意升级/降级版本以使其正常运行。

涂鸦

您可以将surefire降级为v2.19

Surefire 2.20上还有一个未解决的问题

以下Surefire配置可用于JUnit5:

<junit.platform.version>1.0.1</junit.platform.version>
<junit.jupiter.version>5.0.1</junit.jupiter.version>
<maven.surefire.plugin.version>2.19</maven.surefire.plugin.version>

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven.surefire.plugin.version}</version>
    <dependencies>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-surefire-provider</artifactId>
            <version>${junit.platform.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.jupiter.version}</version>
        </dependency>
    </dependencies>
</plugin>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法使用Maven执行Junit5测试

Maven不会运行JUnit5测试

用junit5隐藏stacktraces的Maven surefire

如何使用Maven运行作为插件安装到Eclipse应用程序的JUnit5测试

如何配置Maven插件以运行Spock和Junit5测试

Maven Surefire Junit测试套件

JUnit 5:是否可以在Maven Surefire插件中设置TestExecutionListener?

Maven(surefire)测试插件排除无法正常工作

Maven Surefire没有运行JUnit 5测试

Maven surefire插件输出测试摘要xml?

Maven surefire插件多次触发测试套件

使用Maven surefire与mpirun运行Junit测试

使用Maven Surefire插件运行JUnit 4和Junit5-2020

Maven surefire 插件 2.22.2 构建失败,用于 Junit 5 测试用例,错误不支持 Spring Boot 中的类文件主要版本 56

缺少 Maven Surefire 插件?

如何使用Maven AND JUnit5标签

JUnit 5 Surefire Maven:如何为动态Web模块项目运行测试?

使用 Apache Maven Surefire 在 Junit 5 平台上运行基于文件的测试

Maven无法识别junit测试

Maven surefire插件-按顺序运行所有测试

maven surefire报告插件未运行测试用例

运行单元测试是否需要Maven surefire插件?

Surefire Maven插件不执行测试之一

尝试使用Maven运行Mockito junit5测试时,java.lang.NoClassDefFoundError:org / junit / platform / commons / PreconditionViolationException

Maven surefire插件永久挂起

Maven Surefire插件+并行构建

Maven Surefire 插件版本混淆

无法使用Maven-Surefire-Report插件生成报告

Maven Surefire找不到测试