使用spring-boot-starter-test做单元测试简单示例

一、jar依赖

复制代码
<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>

二、demo示例

复制代码
**@SpringBootTest**
public class Test {

    //  要引入的Bean使用@Autowired注入

    //  在要测试的方法上添加@org.junit.Test注释
    **@org.junit.Test**
    public void test(){
        System.out.println("~~~~~~~~~~~~~~~~~");
    }

}

使用@SpringBootTest和@org.junit.Test两个注解

三、demo运行

相关推荐
NE_STOP9 小时前
Vide Coding--AI编程工具的选择
java
码云数智-园园10 小时前
C++20 Modules 模块详解
java·开发语言·spring
程序员黑豆10 小时前
JDK 下载安装与配置详细教程
java·前端·ai编程
霸道流氓气质10 小时前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务
小宇宙Zz10 小时前
Maven依赖冲突
java·服务器·maven
swordbob10 小时前
NIO的channel中什么是 fd(File Descriptor,文件描述符)
java·开发语言·nio
于先生吖10 小时前
SpringBoot对接大模型开发AI命理测算系统:八字排盘与AI解析接口源码全解
人工智能·spring boot·后端
咖啡八杯11 小时前
GoF设计模式——享元模式
java·spring·设计模式·享元模式
十五喵源码网11 小时前
基于springboot2+vue2的租房管理系统
java·毕业设计·springboot·论文笔记
摇滚侠11 小时前
IDEA 创建 Java 项目 手动整合 SSM 框架
java·ide·intellij-idea