首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >默认保证不使用Spring Boot执行测试

默认保证不使用Spring Boot执行测试
EN

Stack Overflow用户
提问于 2021-04-08 05:29:13
回答 1查看 184关注 0票数 0

我正在做一个非常简单的Spring Boot 2.4.2项目,使用BOM:

代码语言:javascript
复制
  <dependency>
    <!-- Import dependency management from Spring Boot -->
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>2.4.2</version>
    <type>pom</type>
    <scope>import</scope>
  </dependency>
</dependencies>

在运行mvn clean verify时,我得到这样的结果:我们看到Surefire 2.12.4没有找到任何测试

代码语言:javascript
复制
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ api-testing --- 
[INFO] Surefire report directory: C:\Users\vincent\IdeaProjects\api-testing\target\surefire-reports

-------------------------------------------------------  T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

我不明白为什么..。我尝试了几种方法,即使不推荐这样做,我也尝试通过在我的pom中添加以下内容来覆盖该版本:

代码语言:javascript
复制
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.22.2</version>
    </plugin>
  </plugins>
</build>

现在我的测试被找到了!

代码语言:javascript
复制
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ api-testing ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running de.vincent.AssetReferentialServiceTest

我真的对这种Spring Boot行为感到惊讶--我想我遗漏了一些东西。但是什么呢?

注意:我的测试是Junit 5测试,我的类路径中没有与Junit 4相关的jars -只有Junit Jupiter 5.7.0和Junit platform 1.7.0

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-09 18:35:06

非常感谢@M. Deinum在评论中指出了这个问题。

当然,使用Spring Boot parent pom对使用正确的插件版本有很大帮助!

代码语言:javascript
复制
<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.4.2</version>
</parent> 

BOM只对依赖项有帮助,对构建插件没有帮助。

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

https://stackoverflow.com/questions/66994359

复制
相关文章

相似问题

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