Springboot junit Springboot整合junit过程解析

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Springboot junit Springboot整合junit过程解析

第十八使徒   2021-04-22 我要评论

对maven项目的pom.xml进行配置

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
  <exclusions>
<!--junit5不需要配置junit-vintage-engine-->
    <exclusion>
      <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
    </exclusion>
  </exclusions>
</dependency>

测试类如图所示

junit5可直接扫描测试的主启动类 也不需要加@runwith注解 只需要加@SpringBootTest 注解 也不需要指定主启动类的class文件

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们