Springboot与junit集成步骤详解是怎样的?
- 内容介绍
- 文章标签
- 相关推荐
本文共计187个文字,预计阅读时间需要1分钟。
配置Maven项目pom.xml文件以添加Spring Boot测试依赖,并排除JUnit Vintage引擎:
xml org.springframework.boot spring-boot-starter-test test org.junit.vintage junit-vintage-engine
对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文件
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。
本文共计187个文字,预计阅读时间需要1分钟。
配置Maven项目pom.xml文件以添加Spring Boot测试依赖,并排除JUnit Vintage引擎:
xml org.springframework.boot spring-boot-starter-test test org.junit.vintage junit-vintage-engine
对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文件
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。

