JUnit 4 + Spring Boot 测试依赖

1.pom导入依赖

复制代码
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

2.在src同目录下创建test/java

3.编写测试类

复制代码
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;



@RunWith(SpringRunner.class)
@SpringBootTest
public class Test1 {

    @Test
    public void testSqlOutput() {
        System.out.println(111);
    }
}
相关推荐
保卫大狮兄1 小时前
设备管理从台账到报废,完整生命周期一次讲清
数据库·设备管理·设备
数据安全技术观察1 小时前
数据动态脱敏:让脱敏策略跟着数据目录走
大数据·网络·数据库
小席是个热心肠2 小时前
Redis的自我学习
数据库·redis·学习
2601_965798472 小时前
Salient Theme Setup Guide for Fast Creative WordPress Sites
数据库·web3·php·wordpress
evans在进步2 小时前
Spring Boot 核心机制详解:可执行 JAR、CORS、静态资源与配置绑定
spring boot·后端·jar
Sayuanni%33 小时前
SpringBoot 从注解到源码:核心知识点总结
java·spring boot·后端
@Mike@3 小时前
09-数据库学习笔记(数据库索引与过滤器)
数据库·笔记
程序员夏洛4 小时前
MySQL 中 count(*)、count(1) 和 count(字段名) 有什么区别?
数据库·mysql
Wang's Blog4 小时前
PostgreSQL笔记34:索引优化策略全景解析——从B-tree到HOT的核心原理与实践
数据库·笔记·postgresql
m0_587383005 小时前
社区家政系统开发实战:从需求分析到上线部署全指南
java·spring boot·spring·需求分析