首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Junit4和JUnit5不选择JUnit5测试

Junit4和JUnit5不选择JUnit5测试
EN

Stack Overflow用户
提问于 2022-04-06 13:32:46
回答 1查看 162关注 0票数 0

我有一个工作环境,包括bom,我不管理,并且JUnit5测试不会被捕获,除非我从import org.junit.Test;导入测试方法的@Test注释,如果我从import org.junit.jupiter.api.Test;导入它们,它们不会被maven surefire插件捕获。我阅读了许多部分,并在一个较小的项目及其工作和纠偏中进行了测试,我不知道在这篇文章中包含了什么内容,这样您就有了足够的信息来了解问题的所在。另外,如果有人可以解释一下我所读到的导入的引擎盖下面是什么,那么JUnit 4和5都需要使用“万无一失”。

代码语言:javascript
复制
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit-jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <!--JUnit Jupiter Engine to depend on the JUnit4 engine and JUnit 4 API  -->
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>${junit-jupiter.version}</version>
    </dependency>

有版本

代码语言:javascript
复制
    <maven.surefire.version>3.0.0-M5</maven.surefire.version>
    <junit-jupiter.version>5.1.0</junit-jupiter.version>

我会很感激的。

请注意,

我的测试都是在src/test/java/.....java

  • methods下进行的,public

  • methods开始于测试,

  • 类以测试

结束

EN

回答 1

Stack Overflow用户

发布于 2022-04-06 16:32:01

发现这种依赖冲突,消除它解决了我的问题。

代码语言:javascript
复制
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-runner</artifactId>
        <version>1.8.2</version>
        <scope>test</scope>
    </dependency>

还更新了2.6.6的spring-boot依赖版本,并与2.3.3.RELEASE发生了问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71767721

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档